<?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: Chinemere</title>
    <description>The latest articles on DEV Community by Chinemere (@chinemere).</description>
    <link>https://dev.to/chinemere</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%2F542069%2Ff628c4fe-739d-4703-a98d-70cd647ef0e3.jpeg</url>
      <title>DEV Community: Chinemere</title>
      <link>https://dev.to/chinemere</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chinemere"/>
    <language>en</language>
    <item>
      <title>Try and Except in Layman's terms</title>
      <dc:creator>Chinemere</dc:creator>
      <pubDate>Mon, 04 Sep 2023 14:59:18 +0000</pubDate>
      <link>https://dev.to/chinemere/try-and-except-in-laymans-terms-3j2b</link>
      <guid>https://dev.to/chinemere/try-and-except-in-laymans-terms-3j2b</guid>
      <description>&lt;p&gt;In Nigerian local parlance, we say things like "coding sweet but na error kill am" meaning that coding is interesting but errors are its undoing...&lt;/p&gt;

&lt;p&gt;What is software engineering without errors though? So errors are bound to occur in whatever project you are working on. No matter your level of expertise, there are moments when errors will humble you and bring you to your knees; That is why we have a concept called ERROR HANDLING.&lt;/p&gt;

&lt;p&gt;In Python, there are three major types of errors. As a developer, It is either you are encountering a syntax error, a runtime error, or a logical error. Understanding these 3 Major types of errors will help you debug your errors faster&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SYNTAX ERRORS&lt;/strong&gt;&lt;br&gt;
Whenever you see a syntax error blablabla.... just know that you have violated a rule in Python. for instance-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def helloworld()
    print("Hello World")

helloworld()

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

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above code is going to throw a syntax error because you forgot to put a double colon ":" while defining the Helloworld function. So you are the one that broke the Python syntax rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RUNTIME ERRORS&lt;/strong&gt;&lt;br&gt;
This error occurs when your logic is 'wack', you did not break any syntax rule, but your logic is incorrect, for instance- in Python or programming you cannot divide any number by zero, if you do, it will throw what is called the ZeroDivisionError.&lt;br&gt;
`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num = 10/0
print(num)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;/p&gt;

&lt;p&gt;In programming, you can't do the above, This logic is unacceptable, so it is going to throw a zeroDivisionError which falls under the Runtime Error.&lt;/p&gt;

&lt;p&gt;Other examples of runtime errors are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TypeError&lt;/strong&gt;: This occurs when you are trying to perform a certain operation on the wrong data type&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; username = "codechief"
  usernameGroup = username + 2
  print(username)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above code snippet will throw a typeError because the variable username is a string, while the action you are trying to perform (username + 2) is only performed on an integer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;IndexError&lt;/strong&gt;
will occur when you try to access an imaginary index, i.e. A list contains 5 elements, but you are trying to access the index of the 7th element... This will never fly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; gender = ["boy", 'girl'] 
  singleGender = gender[4]
  print(singleGender)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above code snippet will throw an error, the length of our list item is 2, but you are trying to access the 4th element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;KeyError&lt;/strong&gt;: Occurs when trying to access a dictionary key that doesn't exist.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;car_color = {"volovo": "red"}
  singleCarColor = car_color['jeep']
  print(singleCarColor)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above code snippet will throw a KeyError because Jeep does not exist in the car_color dictionary&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NameError&lt;/strong&gt;: Arises when a variable or name is used without being defined.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; def fullname():
      print(lastname)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above code snippet will throw a NameError because lastname was not defined or assigned any value before the point where it is being printed out.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;FileNotFoundError&lt;/strong&gt;: This occurs when trying to open a file that doesn't exist.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;LOGICAL ERRORS&lt;/strong&gt;&lt;br&gt;
Also known as semantic errors, these errors do not cause the program to crash or raise any error at all, you won't just get the desired result. logical errors are caused by flawed program logic; You need meticulousness to debug and fix these kinds of errors because it displays no error message whatsoever, but your program will just refuse to behave as expected.&lt;/p&gt;

&lt;p&gt;Now that we understand the major types of errors that we have. Let's look at one of the ways by which we can handle some of these errors.&lt;/p&gt;

&lt;p&gt;TRY and EXCEPT blocks are used to catch and handle errors that may occur during the execution of a code block.&lt;/p&gt;

&lt;p&gt;What do I mean by this? There are some errors that you anticipate. i.e. you know that there is a probability of this particular block of code throwing an error, so you use the Try and Except block to catch the error.&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import urllib.request

def network(): 
    response = urllib.request.urlopen('http://www.google.com', timeout=1)
    return "You are online."

network()
if __name__ == "__main__":
    result = network()
    print(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The code above defines a function named network that checks whether your internet connection is available by attempting to open a connection to the Google website (&lt;a href="http://www.google.com"&gt;http://www.google.com&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;If you are connected to the internet, it returns " You are online" but if you are offline, or when you try to put off your internet connection; it generates this truckload of errors as seen below-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FEBPa-kS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zf9ugsuzf5w1u0e53vh5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FEBPa-kS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zf9ugsuzf5w1u0e53vh5.jpg" alt="Image description" width="800" height="490"&gt;&lt;/a&gt;&lt;br&gt;
Now, let us introduce the try and except block to the same lines of code&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import urllib.request
def network():
    try:
        response = urllib.request.urlopen('http://www.google.com', timeout=1)
        return "You are online"
    except Exception as e:
        return "error: {}".format(e)

network()
if __name__ == "__main__":
    result = network()
    print(result)

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

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
Disconnect your internet and you will get this error-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PpKzTUu4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4tjg7wmhowajln2d1p1d.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PpKzTUu4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4tjg7wmhowajln2d1p1d.jpg" alt="Image description" width="672" height="108"&gt;&lt;/a&gt;&lt;br&gt;
Between the first error and the second error, you can agree with me that the second error looks less intimidating and less daunting. But that is not the catch; The Try and Except block is so helpful because you get to customise your errors however you want. you can use the Try and Except block to design your own error message that is short, clear, and concise.&lt;/p&gt;

&lt;p&gt;So instead of getting this error:  that doesn't help anyone or point to where the error is coming from. you get to customise it to something like 'you are offline' or any message of your choice.&lt;/p&gt;

&lt;p&gt;Take a look at this:&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import urllib.request
def network():
    try:
        response = urllib.request.urlopen('http://www.google.com', timeout=1)
        return "You are online"
    except Exception as e:
        return "You are offline"

network()
if __name__ == "__main__":
    result = network()
    print(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;/p&gt;

&lt;p&gt;When you run the above lines of code while your internet is disconnected, you get a more friendly error message that was designed by you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J263TKE4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e5agwkvo0ss6ftgzlglm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J263TKE4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e5agwkvo0ss6ftgzlglm.jpg" alt="Image description" width="780" height="167"&gt;&lt;/a&gt;&lt;br&gt;
I hope you can see the difference between when You use the Try and Except block and when you do not.&lt;/p&gt;

&lt;p&gt;Some of the advantages of using the Try and Except Block are as follows:&lt;/p&gt;

&lt;p&gt;Program robustness: Try and Except block will prevent your program from stopping abruptly at the sight or encounter of an error. it handles errors gracefully. It helps to provide appropriate feedback, it gives you a whole lot of clues as to where the bug is in your code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debugging:&lt;/strong&gt; Exception messages often provide valuable information about what went wrong, where it went wrong, and even how it went wrong in your code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User-Friendly&lt;/strong&gt;: Exception messages can be used to create a user-friendly experience for users. it points them to what is wrong, or the next step to take.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing&lt;/strong&gt;: Are you a serious developer if you do not write unit tests for your code? Your guess is as good as mine; Exceptions make it easier to write unit tests. You can simulate different error scenarios and ensure that your code handles them correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Control Flow&lt;/strong&gt;: Exceptions can be used to make conditional statements in place of 'Ifs' and Else statements when trying to figure out the possibilities of an error occurring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When To Use Try and Except&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use the Try and Except Block When working with external resources&lt;/strong&gt; like files, network connections, or database connections, you should use try and except blocks to ensure that these resources are properly closed or released, even if an error occurs. eg.&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try:
     file = open("example.txt", "r")
     data = file.read()
 except FileNotFoundError:
     print("The file does not exist.")
 finally:
     file.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above lines of code can be interpreted as doing the following-&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: TRY and open this file&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Read the contents of the file,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;: Peradventure the file is not found or does not exist, raise an exception or please print the words 'The file does not exist'&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;: Finally! After all is said and done, close the file if you found the file or not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use the Try and Except Block When taking user input&lt;/strong&gt; : You can use try and except to validate and handle input errors, ensuring that your program doesn't crash due to invalid user input. As A developer, the last person to trust is your users, You cannot trust them to always input the correct data at all times, even when there are clear instructions on what to input. You will still find rule breakers, so you have to prepare for them.&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try:
     file = open("example.txt", "r")
     data = file.read()
 except FileNotFoundError:
     print("The file does not exist.")
 finally:
     file.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above sample code attempts to get the user's age as input and convert it to an integer. If the user enters something that cannot be converted to an integer (e.g., a non-numeric string like John, or Mary), it catches the ValueError exception and displays an error message to inform the user that they need to enter a valid integer or number. This helps prevent your program from crashing due to invalid input and provides a better user experience by handling errors gracefully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use The Try and Except Block when you need to make Network and External API Calls:&lt;/strong&gt; When making network requests or accessing external APIs, use try and except to handle network-related errors, such as timeouts or connectivity issues.&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

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

 try:
     response = requests.get("https://www.google.com/")
     response.raise_for_status()  # Check for HTTP error status codes
 except requests.exceptions.RequestException as e:
     print(f"An error occurred: {e}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above code snippet demonstrates how to use the requests library to make an HTTP request to a URL and handle potential errors that might occur during the request. By using the try and except blocks, it ensures that the program doesn't crash due to network issues or HTTP errors and provides feedback to the user or logs the error for debugging purposes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use the Try and Except Block when you want to carry out file operations&lt;/strong&gt; : When reading, writing, or manipulating files, use try and except blocks to handle file-related errors like file not found or permissions issues.&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try:
     with open("books.txt", "r") as file:
         content = file.read()
 except FileNotFoundError:
     print("The file does not exist.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above code is used to open and read the contents of a file named "books.txt." If the file does not exist or there is any other issue when opening the file, it catches the FileNotFoundError exception and prints an error message.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use the Try and Except Block when carrying out Database Operations&lt;/strong&gt;: When working with databases, use try and except to handle database-related errors such as connection issues or SQL query errors.&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

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

try:
    conn = sqlite3.connect("mydb.db")
    cursor = conn.cursor()
    cursor.execute("SELECT * FROM Users")
except sqlite3.Error as e:
    print(f"Database error: {e}")
finally:
    conn.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above code snippet is a basic example of using the sqlite3 module to connect to an SQLite database, perform a query that may result in an error (table not found), handle the database-related error using a try and except block, and ensure that the database connection is closed properly using a finally block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Know When To Draw The Line&lt;/strong&gt;&lt;br&gt;
There are lots of scenarios that will necessitate the use of the Try and Except block, However, you must be careful; while try and except blocks are valuable for error handling, it's essential to use them judiciously and at the appropriate time. You must be able to strike a balance between handling exceptions gracefully and keeping your code clear and maintainable.&lt;/p&gt;

&lt;p&gt;Excess use of the Try and Except block has its consequences. It can obscure your logic, reduce the performance of your application, make debugging more challenging, and make the entire codebase difficult to maintain.&lt;/p&gt;

&lt;p&gt;Do not get carried away and start using exceptions for things that If statements can conveniently do. A great tip will be to use exceptions for conditions that are beyond you. for instance network errors, as the developer, you cannot control your user's network situations, If you are making an API call, The other application might be experiencing downtime, it's not your fault, there is no way you can control that, such conditions are perfect for the use of the Try and Except Block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How To Use The Try And Except Block&lt;/strong&gt;&lt;br&gt;
There is no great lecture on how to use the Try and Except block in Python other than:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Identifying the code that might Raise an exception or error&lt;br&gt;
.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wrapping the code in question in a 'Try' Block&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Handling the exception/error within the 'Except' block&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Setting the 'Finally' Block to be executed regardless of whether an exception occurred. (This is mostly optional)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try:
    # Code that may raise an exception
except SpecificExceptionType as e:
    # Handle SpecificExceptionType
except AnotherExceptionType as e:
    # Handle AnotherExceptionType
finally:
#code to run whether an exception occurred or not
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
Here is a simple example&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try:
    user_input = input("Enter a number: ")
    number = int(user_input)
    print(f"You entered the number: {number}")
except ValueError as e:
    print(f"Invalid input: {e}")
finally:
    print("Nothing to be done")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
Sometimes one might anticipate more than one exceptionType to occur, you can just stack them all up, one after the other.&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x= int(input("Insert a Numerator: "))
y = int(input("Insert a denominator: "))
try:
    result = x/y
    print(result)
except ValueError as e:
    print("error: {}".format(e))
except ZeroDivisionError as e:
    print("error: {}".format(e))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
The above code snippet allows the user to input a numerator and a denominator. It then attempts to perform division and handles two specific types of exceptions: ValueError (for non-integer input) and ZeroDivisionError (for dividing by zero). If any of these exceptions occur, the code gracefully handles them by displaying an error message, preventing the program from crashing.&lt;/p&gt;

&lt;p&gt;That is it!!! This wraps up my little rant about the Try and Except Block. Take-home lessons will be to use the TRY and EXCEPT blocks where they are genuinely needed; Avoid using exceptions for routine flow control and Keep the error-handling logic as close as possible to where the error occurs.&lt;/p&gt;

&lt;p&gt;Thanks for coming to my TED Talk, If you enjoyed this, kindly leave a comment, and follow me on:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Twitter: &lt;a class="mentioned-user" href="https://dev.to/codemistress1"&gt;@codemistress1&lt;/a&gt; &lt;br&gt;
Linkedin: linkedin.com/in/chinemere-chukwu&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>errors</category>
      <category>backenddevelopment</category>
    </item>
    <item>
      <title>7 Unique and Underrated Python Libraries</title>
      <dc:creator>Chinemere</dc:creator>
      <pubDate>Fri, 25 Aug 2023 11:23:20 +0000</pubDate>
      <link>https://dev.to/chinemere/7-unique-and-underrated-python-libraries-l6e</link>
      <guid>https://dev.to/chinemere/7-unique-and-underrated-python-libraries-l6e</guid>
      <description>&lt;p&gt;I believe that all stakeholders in the tech industry have agreed and come to a unanimous decision that Python is an easy-going programing language. If ever it was a debate, I think it was laid to rest long ago.&lt;/p&gt;

&lt;p&gt;From &lt;a href="http://www.python.org" rel="noopener noreferrer"&gt;www.python.org&lt;/a&gt;, Python is a programming language that lets you work quickly and integrate systems more effectively. Long story short Python is a programming language that is beginner-friendly, yet so powerful to a fault. So you want to build an E-commerce Application, a social network, a mobile application, a desktop application, or venture into game development, Robotics, natural language processing, data science, IoT (Internet of Things), and cybersecurity among others, Python is that all-round language that other languages wish they could become.&lt;/p&gt;

&lt;p&gt;Python has one of the broadest libraries among programming languages. Its prevalence and flexibility have prompted the production of an immense number of libraries for different purposes including web development, data analysis, machine learning, and automation and that's just the beginning. While other languages like JavaScript and Java likewise have countless libraries, Python's usability, relevance, and accessibility of libraries have added to its far and wide reception and the improvement of a rich library ecosystem system. In any case, the specific number of libraries can fluctuate over the long run, and new libraries are continually being created in different languages non-stop.&lt;/p&gt;

&lt;p&gt;It's obvious that generally perceived Python libraries like SQLAlchemy, NumPy, Pandas, OpenCV, beautiful soup, and Matplotlib have sort of built their tent in the minds of most developers. Notwithstanding, there's an entire universe of unpopular, uncommon, underappreciated, and vastly underrated Python libraries waiting to be discovered or rather, they have been discovered but are not fully being utilized.&lt;/p&gt;

&lt;p&gt;In this article, we will explore some very useful Libraries that have been hugely ‘disrespected’ by the seeming neglect and lack of constant use of the Libraries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Faker&lt;/strong&gt;&lt;br&gt;
So you want to test your application with semi-real data? Stress no more, Fake Data was built to help you generate fake data such as full names, addresses, emails, gender, etc. to help you work smartly. You can visit &lt;a href="https://faker.readthedocs.io/en/master" rel="noopener noreferrer"&gt;https://faker.readthedocs.io/en/master&lt;/a&gt; for basic installation instructions and application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arrow&lt;/strong&gt;&lt;br&gt;
As a newbie, you must be tired of Date formatting and all the struggles that come with manipulating Dates. The Arrow Library provides you with A logical and user-friendly method for producing, modifying, editing, and converting dates, times, and timestamps. It helps you work with Date and Time with fewer codes in the shortest possible time. Want to try it out? Click here &lt;a href="https://pypi.org/project/arrow" rel="noopener noreferrer"&gt;https://pypi.org/project/arrow&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pandas-Profiling/ydata-Profiling&lt;/strong&gt;&lt;br&gt;
Data Science geeks will love this Library. It provides a one-line Exploratory Data Analysis (EDA) experience in a consistent and fast solution. At the time of writing this article, the module has been renamed to ydata-Profiling, it is used to create comprehensive profiling reports for a pandas data frame. It broadens insights into data delivery and distribution. You can explore more of its features at &lt;a href="https://pypi.org/project/pandas-profiling" rel="noopener noreferrer"&gt;https://pypi.org/project/pandas-profiling&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rich&lt;/strong&gt;&lt;br&gt;
As the name implies, it is rich in beautifying terminal outputs. Take a sneak peek of what we are talking about&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fersra20a3qnd1hq3cz9c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fersra20a3qnd1hq3cz9c.png" alt="A terminal with beautiful letterings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You do not have to code in a boring black background and white text terminal. The Rich Library helps you to easily output colorful tables, progress bars, and syntax highlighting. Check out more of its features at &lt;a href="https://pypi.org/project/rich" rel="noopener noreferrer"&gt;https://pypi.org/project/rich&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PyTorch Geometric&lt;/strong&gt;&lt;br&gt;
Deep Learning Enthusiast get in here, you are going to love this specialized library made up of various techniques for deep learning. Designed for dealing with irregular and graph-structured data in deep learning tasks. Software Engineers use this library to train and create neural networks that process and learn from complex relational data represented as graphs. For more on how this tool works, check it out on &lt;a href="https://pytorch-geometric.readthedocs.io/en/stable" rel="noopener noreferrer"&gt;https://pytorch-geometric.readthedocs.io/en/stable&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Peewee&lt;/strong&gt;&lt;br&gt;
This is a Python ORM (Object-Relational Mapping) library that supports SQLite, MySQL, PostgreSQL, and Cockroach databases. It basically helps software developers work with databases using Python class methods instead of battling with SQL queries. It is a very expressive object-relational mapper (ORM) applied to joining relational data with Python objects. You can access it here &lt;a href="https://docs.peewee-orm.com/en/latest" rel="noopener noreferrer"&gt;https://docs.peewee-orm.com/en/latest&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Streamlit&lt;/strong&gt;&lt;br&gt;
Streamlit is an Open Source Python library that is used to create beautiful web apps. Say goodbye to HTML, CSS, and Javascript forever with this fun and creative library.&lt;/p&gt;

&lt;p&gt;It is most useful for data science applications and machine learning projects. With Streamlit, your dashboard applications and visualization is about to come alive. With a simple and short line of Python code, you will get your application blazing all the way visually. You can get more out of it here &lt;a href="https://docs.streamlit.io" rel="noopener noreferrer"&gt;https://docs.streamlit.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There you have it. There are tons of Python libraries out there waiting to be explored. Which of these libraries will you start using to make you work better and smarter?&lt;/p&gt;

&lt;p&gt;Do not hesitate to connect with me on Twitter and LinkedIn for more tech-related articles and discussions.&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>python</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
