How Do I Remove/Delete Folders That Are Not Empty?

In this post, we will learn How to remove/delete the folders that are not empty where we can use the rmtree function which is defined in the module called ‘shutil’ which is used for deleting the folder given at any particular location. Deleting Folders As we know we can delete the as a whole and … Read more

How Should I Use ‘has_key()’ or ‘in’ on Python Dicts?

In this post we will get to know how Should we use ‘has_key()’ or ‘in’ on Python dicts where we can use the same using ‘in keyword to check if a key is present in a dictionary although it (has_key’) is removed from the latest versions of python like python3 and latest version. Use of … Read more

How Do I Remove All Packages Installed By Pip?

In this post, we will learn more about How to remove all packages installed by pip which we can perform using a fixed number of steps by following the commands and directions given there and executing the where we can also perform the same even uninstall pip setuptools which will help in removing both pip … Read more

Docstrings | What Are The Most Common Python Docstring Formats?

In this post, we will learn more about the most common Python docstrings formats which it is used for documenting the functions, classes, and modules in python, Which are defined in triple quotes which say string enclose and provide critical information about how to see the code. Docstring As there are a number of formats … Read more

How To Print Numbers Using Commas As Thousands Separators?

In this post, we will learn more about How to print a Numbers using commas as thousands of separators where we can use the format method along with “{:,.0f}” which is a format of the string. Numbers Using Commas Using commas in digits makes it easy for us to understand the digit and read the … Read more

How Do I Sort A List Of Objects Based On An Attribute Of The Objects?

In this post, we will learn How to Sort a list of objects based on an attribute of the objects which we can perform using the sort built in function even we can do the same thing using the sorted function to and here we will discuss both the examples and execution with the help … Read more

Exception | How Do You Test That A Python Function Throws An Exception?

In this post, we will learn How to test that a Python function throws an Exception where we can use the assert raises method from the in built module called the ‘unit test’ module which we can directly import from the library. Catching Exception Here we have given an example where we can see how … Read more

Proper Way To Declare Custom Exceptions in Modern Python?

In this post, we will learn more about the Proper way to declare custom Exceptions in modern Python where we can inherit the properties of the exception class to design a custom exception class to catch any custom exceptions, to learn have a look at example given below. Custom Exceptions Custom inheritance is nothing but … Read more

Underscore | What is the Meaning of Single and Double Underscore Before an Object Name?

In this post, we will learn more about What is the meaning of single and double underscores before an object name. where each single and double have different use in python which we will discuss below with example to explain all these and get a clear idea of both.  Single Underscore As we know a … Read more

Meaning of @Classmethod And @Staticmethod For Beginners

In this post, we will get to know the Meaning of classmethod and @staticmethod for beginner where they both are decorators which we can use for defining the method with the class we are working on, Moreover, these are the methods created for calling of the class without creating an instance of the class. Which … Read more

%d bloggers like this: