<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Siddhartha Chowdhury</title>
    <description>The latest articles on DEV Community by Siddhartha Chowdhury (@sxddhxrthx).</description>
    <link>https://dev.to/sxddhxrthx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F593546%2Fd434cbcd-9e21-49d7-822e-ea39bf475535.png</url>
      <title>DEV Community: Siddhartha Chowdhury</title>
      <link>https://dev.to/sxddhxrthx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sxddhxrthx"/>
    <language>en</language>
    <item>
      <title>Introduction to Dependency Injection in Python</title>
      <dc:creator>Siddhartha Chowdhury</dc:creator>
      <pubDate>Sat, 20 Mar 2021 07:17:59 +0000</pubDate>
      <link>https://dev.to/sxddhxrthx/introduction-to-dependency-injection-in-python-35c</link>
      <guid>https://dev.to/sxddhxrthx/introduction-to-dependency-injection-in-python-35c</guid>
      <description>&lt;p&gt;Motivation: After mindlessly creating projects and writing code that implements somethings but never made any sense from a bird's eye view for almost 11 years, it was time to learn something that would help me understand design patterns and write code that actually made sense and looked aesthetic (bringing in Instagram vibes to DEV.to 😁). Recently came across Dependency Injection in Python at work and thought of giving it a try.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Dependency Injection (DI) in Python?
&lt;/h3&gt;

&lt;p&gt;DI is a common design pattern used in most modern (and not so modern) programming languages. Yet it remains an underutilized functionality in Python. A lot of people speak for and against the use of DI in Python which is a topic for another day.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use Dependency Injection (DI) in Python?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://pypi.org/project/dependency-injector/"&gt;&lt;code&gt;dependency-injector&lt;/code&gt;&lt;/a&gt; (&lt;a href="https://python-dependency-injector.ets-labs.org/"&gt;docs&lt;/a&gt;) is python library that provides a framework which enables you to implement DI and IoC in Python. &lt;/p&gt;

&lt;h2&gt;
  
  
  GETTING STARTED
&lt;/h2&gt;

&lt;p&gt;Two key components of &lt;code&gt;dependency-injector&lt;/code&gt; are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;containers&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;providers&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;providers&lt;/code&gt; create object and inject the dependencies. &lt;code&gt;Resource&lt;/code&gt;, &lt;code&gt;Factory&lt;/code&gt;, &lt;code&gt;Configuration&lt;/code&gt;, &lt;code&gt;Singleton&lt;/code&gt;, &lt;code&gt;Callable&lt;/code&gt;, etc. are some of the provider types and this is not an exhaustive list but we'll keep our discussion limited around these types to justify the scope of the article.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;container&lt;/code&gt; is merely a collection of &lt;code&gt;providers&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Keep the below point in mind as it will be the only mantra to live by while implementing DI:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Each &lt;code&gt;provider&lt;/code&gt; is callable. Whenever you need an object of particular type, just call the corresponding provider as you would call a function.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Enough with the theory and now,&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's get our hands dirty:
&lt;/h2&gt;

&lt;p&gt;We'll start by importing &lt;code&gt;containers&lt;/code&gt; and &lt;code&gt;providers&lt;/code&gt; from &lt;code&gt;dependency_injector&lt;/code&gt; package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from dependency_injector import containers, providers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll create two classes &lt;code&gt;School&lt;/code&gt; and &lt;code&gt;Student&lt;/code&gt;. A &lt;code&gt;Student&lt;/code&gt; goes to a particular &lt;code&gt;School&lt;/code&gt;, so &lt;a&gt;&lt;code&gt;Student&lt;/code&gt; has a dependency on &lt;code&gt;School&lt;/code&gt;.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's look at the attributes of these classes:&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;School&lt;/code&gt;:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;schoolname&lt;/code&gt;: &lt;code&gt;str&lt;/code&gt; - Every school has a name, obviously!&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;city&lt;/code&gt;: &lt;code&gt;str&lt;/code&gt; - Where do you study? A school named &lt;code&gt;&amp;lt;schoolname&amp;gt;&lt;/code&gt; in &lt;code&gt;&amp;lt;city&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;board&lt;/code&gt;: &lt;code&gt;str&lt;/code&gt; - What education board does your school follow? C.B.S.E.? I.C.S.E. or State Board?&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;Student&lt;/code&gt;:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt;: &lt;code&gt;str&lt;/code&gt; - Again, every student has a name, obviously!&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;age&lt;/code&gt;: &lt;code&gt;int&lt;/code&gt; - How old are you? I am &lt;code&gt;&amp;lt;age&amp;gt;&lt;/code&gt; years old.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;school&lt;/code&gt;: &lt;code&gt;School&lt;/code&gt; - In which school do you study? I study at &lt;code&gt;&amp;lt;schoolname&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;grade&lt;/code&gt;: &lt;code&gt;int&lt;/code&gt; - What grade you are in? I am in &lt;code&gt;&amp;lt;grade&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class School:

    def __init__(self, name: str, city: str, board: str):
        self.schoolname = name
        self.city = city
        self.board = board

    def get_schoolname(self):
        print(f"school name is {self.schoolname}")


class Student:

    def __init__(self, name: str, age: int, grade: int, school: School):
        self.name = name
        self.age = age
        self.grade = grade
        self.school = school
        #super().__init__(school, city, board)

    def get_students(self):
        student_detail = f"""
            Student Name: {self.name}
            Student Age: {self.age}
            Student Grade: {self.grade}
            School: {self.school.schoolname}
            Exam Board: {self.school.board}
            City: {self.school.city}
        """

        print(student_detail)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create dependencies we'll create a class called &lt;code&gt;Container&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Container(containers.DeclarativeContainer):

    school = providers.Singleton(
        School,
        "Kendriya Vidhyala",
        "C.B.S.E.",
        "Bina"
    )

    student = providers.Factory(
        Student,
        "Siddhartha",
        28, 12,
        school
    )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have created 2 providers, &lt;code&gt;school&lt;/code&gt; and &lt;code&gt;student&lt;/code&gt;. To initialize a factory provider, we use &lt;code&gt;providers.Factory&lt;/code&gt; and provide a class as the first argument and other arguments are the class attributes required to initialize the class. Singleton provider works in the same way as a factory provider with an added restriction that it will only create a single object which will be memorized in the entire application lifetime.&lt;/p&gt;

&lt;p&gt;Since many student go to a single school, we have established that relationship by making Student a Factory and School a Singleton.&lt;/p&gt;

&lt;p&gt;Since, we have established this fact above that &lt;code&gt;Student&lt;/code&gt; has a dependency on &lt;code&gt;School&lt;/code&gt;, we'll now establish this dependency. If you watch carefully, after creating the &lt;code&gt;school&lt;/code&gt; dependency will have injected it into student. Look close and observe the last argument of student provider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;school = providers.Singleton(
    School,
    "Kendriya Vidhyala",
    "C.B.S.E.",
    "Bina"
)

student = providers.Factory(
    Student,
    "Siddhartha",
    28, 12,
    school
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how we create and inject dependencies. Now all we need to do is create a single container object and wire the modules together and it will take care of all the underlying object creation and their injections at suitable positions. This is how we do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;container = Container()
container.wire(modules=[sys.modules[__name__]])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now whenever we need to see the Student, we call the get_student() function using the student provider.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;student = Container.student()
student.get_students()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what the code looks in it's entirity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sys
from dependency_injector import containers, providers
from dependency_injector.wiring import inject, Provide

class School:

    def __init__(self, name: str, city: str, board: str):
        self.schoolname = name
        self.city = city
        self.board = board

    def get_schoolname(self):
        print(f"school name is {self.schoolname}")

class Student():

    def __init__(self, name: str, age: int, grade: int, school: School):
        self.name = name
        self.age = age
        self.grade = grade
        self.school = school
        #super().__init__(school, city, board)

    def get_students(self):
        student_detail = f"""
            Student Name: {self.name}
            Student Age: {self.age}
            Student Grade: {self.grade}
            School: {self.school.schoolname}
            Exam Board: {self.school.board}
            City: {self.school.city}
        """

        print(student_detail)


class Container(containers.DeclarativeContainer):

    school = providers.Factory(
        School,
        "Kendriya Vidhyala",
        "C.B.S.E.",
        "Bina"
    )

    student = providers.Factory(
        Student,
        "Siddhartha",
        28, 12,
        school
    )


def main():

    student = Container.student()
    student.get_students()


if __name__ == "__main__":

    container = Container()
    container.wire(modules=[sys.modules[__name__]])
    main()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run the code this will be your expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Student Name: Siddhartha
Student Age: 28
Student Grade: 12
School: Kendriya Vidhyala
Exam Board: C.B.S.E. 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To be honest, this example can easily be implemented using inheritence. But when your code bigger and bigger with tens and hundreds of classes, keeping a track of all the objects and the their position in inheritence tree is extremely difficult. This is where DI comes handly.&lt;/p&gt;

&lt;p&gt;It looks a bit overwhelming at the start but once you understand it, it makes your code extremly flexible to change and test.&lt;/p&gt;

&lt;p&gt;I'll be writing a detailed article with advanced use of DI in a real-world use-case somewhere in near future. So if you found this article helpful, your feedback would be genuinely appreciated so that I can avoid similar pitfalls in upcoming articles&lt;/p&gt;

</description>
      <category>designpattern</category>
      <category>python</category>
      <category>advanced</category>
      <category>dependencyinjection</category>
    </item>
    <item>
      <title>Practical Way to Get Started With Python</title>
      <dc:creator>Siddhartha Chowdhury</dc:creator>
      <pubDate>Sat, 13 Mar 2021 10:51:36 +0000</pubDate>
      <link>https://dev.to/sxddhxrthx/practical-way-to-get-started-with-python-1c3i</link>
      <guid>https://dev.to/sxddhxrthx/practical-way-to-get-started-with-python-1c3i</guid>
      <description>&lt;p&gt;No matter the what the use case is, Python can always be utilized to solve the problem statement. Maybe, not in the most efficient way but it does solve your problem. And the best part is, it's one of the easiest Programming language to learn in today's date. And here's how you can get started with it in the most practical way possible.&lt;/p&gt;

&lt;p&gt;One can skim through the internet trying to find ways to learn Python and most of the articles/tutorial/courses you find will tell you how to use Python's constructs, conditional statements, iterations, OOP concepts, a few libraries like NumPy, Pandas etc. and that's a really good starting point. But the question always lies, WHAT NEXT?&lt;/p&gt;

&lt;p&gt;This article talks about what to do next to implement the basics of Python and getting comfortable with the language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start with a small project to read a file from filesystem and log all the events happening inside the code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All those who want to explore on their own may now close this tab and move ahead with googling "How to read a file in Python?" or "How to log events in Python?". Others who would like a guiding hand, may follow along this article.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reading files in Python.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We'll start by reading a simple text file.&lt;br&gt;
For starters create a text file manually and paste loren ipsum statement into it.&lt;/p&gt;

&lt;p&gt;Now to read this file, we need 2 objects:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Path to this file&lt;/li&gt;
&lt;li&gt;IO object to perform read operation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From a bunch of filesystem libraries, I find &lt;a href="https://docs.python.org/3/library/pathlib.html"&gt;&lt;code&gt;pathlib&lt;/code&gt;&lt;/a&gt; the most intuitive. You might like to explore more on similar libraries as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pathlib import Path

file_path = Path.cwd() / 'loren_ipsum.txt'

with open(file_path, 'r') as text_file:
    file_data = text_file.read()

print(file_data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see what's happening here.&lt;/p&gt;

&lt;p&gt;We import Path module from pathlib package. &lt;code&gt;Path.cwd()&lt;/code&gt;'s &lt;code&gt;__str__()&lt;/code&gt; implementation returns the string representation of pathlib object for &lt;em&gt;current working directory&lt;/em&gt;. &lt;code&gt;/ 'loren_ipsum.txt'&lt;/code&gt; uses the operator overloading concept to append the text file name in the path.&lt;/p&gt;

&lt;p&gt;Using the context manager &lt;code&gt;with&lt;/code&gt; we then &lt;code&gt;open()&lt;/code&gt; the text file as &lt;code&gt;text_file&lt;/code&gt; object in reading &lt;code&gt;('r')&lt;/code&gt; mode. And then we print the data. Pretty easy stuff, right?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Obtaining resources using &lt;code&gt;with&lt;/code&gt; is generally a good idea because then you won't have to worry about releasing those resources.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now we move to the logging part.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Logging in Python&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's quite easy to implement basic logging functionality in Python. All you need to do is import &lt;a href="https://docs.python.org/3/library/logging.html"&gt;&lt;code&gt;logging&lt;/code&gt;&lt;/a&gt; package, set logging configurations using &lt;code&gt;logging.basicConfig()&lt;/code&gt; method and start logging events using &lt;code&gt;logging.info('Event Here')/logging.warning('Warning Here')&lt;/code&gt; etc. methods.&lt;/p&gt;

&lt;p&gt;Here's how it looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import logging

logging.basicConfig(filename="applog.log", datefmt="%d-%m-%Y %H:%M:%S", level=logging.DEBUG, format="%(asctime)s - %(levelname)s %(message)s")

logging.debug("This is a DEBUG MESSAGE")
logging.info("This is a INFO MESSAGE")
logging.warning("This is a WARNING MESSAGE")
logging.critical("This is a CRITICAL MESSAGE")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll take a advanced step and configure logging in detail to understand underlying concepts.&lt;/p&gt;

&lt;p&gt;We'll start with importing logging package as usual&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import logging
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Logging package basically requires 4 objects to work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logger Object: Logger is never instantiated directly but through a module-level function called &lt;code&gt;getLogger(logger_name)&lt;/code&gt;. It exposes interfaces which application code can directly consume. If no logger is defined, the default logger, Root Logger, will be used.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger = logging.getLogger("newLogger")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Handlers: Handlers is also never instantiated directly. There are mostly 2 kinds of handlers used, one being the &lt;code&gt;StreamHandler&lt;/code&gt; which outputs logs directly into the console window and the other being &lt;code&gt;FileHandler&lt;/code&gt; which outputs the logs in a file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console_handler = logger.StreamHandler()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Log Level: Logging in general, concerns with 5 kinds of message namely, DEBUG, INFO, ERROR, WARNING and CRITICAL.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both Logger and Handler requires log level to be specified to them.&lt;br&gt;
Level for Logger determines the type of logs to be collected by the logger. Level for Handler determines the type of logs to be displayed by the handler.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
If I set logger level to &lt;code&gt;ERROR&lt;/code&gt;, then logger will only collect &lt;code&gt;ERROR&lt;/code&gt;, &lt;code&gt;WARNING&lt;/code&gt; and &lt;code&gt;CRITICAL&lt;/code&gt; logs but not &lt;code&gt;DEBUG&lt;/code&gt; and &lt;code&gt;INFO&lt;/code&gt; logs. And then if I set handler level to &lt;code&gt;WARNING&lt;/code&gt; then handler will be display &lt;code&gt;WARNING&lt;/code&gt; and &lt;code&gt;CRITICAL&lt;/code&gt; logs and &lt;code&gt;ERROR&lt;/code&gt; logs will be ignored.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger.setLevel(logging.DEBUG)
console_handler.setLevel(logging.DEBUG)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Formatter: Formatter object takes in, what will be format of logs being displayed on console or written into the log file, as an argument.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the most generic format of a log would be:&lt;/p&gt;

&lt;p&gt;formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')&lt;/p&gt;

&lt;p&gt;Now all we need to attach this formatter to the handler and then attach the handler to the logger&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console_handler.setFormatter(formatter)
logger.addHandler(console_handler)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are done with setting up the logging in our application.&lt;/p&gt;

&lt;p&gt;Now we can put all the code together which would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pathlib import Path
import pretty_errors
import logging

app_name = "Logging APP"

logger = logging.getLogger(app_name)
logger.setLevel(logging.DEBUG)

console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)

formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

console_handler.setFormatter(formatter)
logger.addHandler(console_handler)

try:
    logger.info("Locating File...")
    file_path = Path.cwd() / 'loren_ipsum.txt'
except FileNotFoundError as e:
    logger.error(f"Locating File Unsuccessful: Error:: {e}")
    raise e

logger.info("File Located!")
logger.info("Opening File")
with open(file_path, 'r') as text_file:
    logger.info("Reading File")
    file_data = text_file.read()
    logger.info("Content of the File is read")
logger.info("File Closed!")
logger.info("Execution Complete")

print(file_data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you run the program, you'll get this output on your screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2021-03-13 16:01:04,442 - Logging APP - INFO - This is a info message
2021-03-13 16:01:04,443 - Logging APP - INFO - Locating File...
2021-03-13 16:01:04,443 - Logging APP - INFO - File Located!
2021-03-13 16:01:04,443 - Logging APP - INFO - Opening File
2021-03-13 16:01:04,444 - Logging APP - INFO - Reading File
2021-03-13 16:01:04,444 - Logging APP - INFO - Content of the File is read
2021-03-13 16:01:04,444 - Logging APP - INFO - File Closed!
2021-03-13 16:01:04,445 - Logging APP - INFO - Execution Complete
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have understood how to write this code, you can go ahead and read more about the objects of &lt;a href="https://docs.python.org/3/library/logging.html"&gt;&lt;code&gt;logging&lt;/code&gt;&lt;/a&gt; library in depth.&lt;/p&gt;

&lt;p&gt;Reading configuration files and logging events are two major components of every application you develop. This mechanism is omnipresent. Once you are comfortable with reading files and logging, consider yourself a notch better than yesterday at any enterprise.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
