Practical solutions

Python How-To's How-To Guides

Solve the problem. Keep building. The collection of Python-related howtos

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Understand Slots in PythonThis article will discuss how the slots constant variable work in Python and how it is any better than using dictionaries. How to Set Maximum Retries for Requests in PythonThis tutorial demonstrates how to set max_retries for requests in Python. How to Set HTTP Proxy Settings in PythonThis tutorial demonstrates how we can set up the HTTP proxy settings within our Python environment. How to Serialize a Python Class Object to JSONThis tutorial educates about serialization in Python and demonstrates Python class JSON serialization. How to Mock Class Attribute in PythonThis tutorial demonstrates how to mock an attribute/member of a class with a mock module. How to Fix Shared Memory Issues & Lock Shared Resources in PythonThis tutorial explains various aspects related to multiprocessing shared memory and demonstrates how to fix issues when we use shared memory. We'll also learn how to use the lock to lock the shared resources in python. How to Compare Two CSV Files and Print Differences Using PythonThis article discusses various methods for comparing two CSV files and printing out the differences in the files. How to Wait for the Async Function to Complete in PythonThis article demonstrates how to create an asynchronous function and use the await keyword to interrupt a process. We'll also learn how to use tasks instead of threads in Python. How to Use Requests Module to Post Form Data in PythonThis tutorial demonstrates different approaches to using the POST method in Python and its properties to send POST requests to the specified URL and when a user needs to send some data o the server. How to Setup Python UnittestIn this article, we discuss what is unit testing and Python unittest framework. Also we discuss how to use setUp() function for unit testing along with an example. How to Peek A Deque in PythonThis tutorial demonstrates how to peek an element of a deque without popping the element in Python. How to Make Random IP Address Generator in PythonThis tutorial will teach you to generate random IP address as string in Python. How to List Virtual Environments in PythonIn this article, we discuss what is a virtual environment in Python and some commands to list them down. How to Get a Return Value From a Thread in PythonThis article is guide to getting the return value from a thread in Python. How to Create N-Grams From Text in PythonThis tutorial shows how to use Python features and libraries to create n-grams from bigram to trigrams. How to Split CSV Into Multiple Files in PythonIn this article, we will learn how to split a CSV file into multiple files in Python. We will use Pandas to create a CSV file and split it into other multiple files. How to Manage Python DependenciesOne of the challenges of using Python is managing dependencies. In this article, we will discuss and learn about the management of Python dependencies. How to Make Compound Interest Calculator in PythonIn this article, we'll discuss the compound interest function and how to implement it in Python. How to Flatten JSON in PythonOne can flatten JSON using conditional statements, loops, and type() function in Python. How to Fix Python IndexError: list assignment index out of rangeIn this article, we'll learn how to fix the Index Error list assignment index out of range error in Python. Furthermore, I'll discuss the different possible solutions to this error which are the append(), and insert() functions. How to Escape Curly Braces Using format() in PythonThis tutorial demonstrates to escape curly brackets in Python using the format() method. How to Escape Curly Braces in F-String in PythonThis tutorial demonstrates how to print curly brackets in output in Python. How to Detect Languages in PythonThis article describes how we can detect languages using Python. We can use Libraries or APIs, language models, and language intersecting sets. Using the Python library is a frequent technique when detecting language in Python. How to Compare Multilevel JSON Objects Using JSON Diff in PythonThis article aims to demonstrate how we can compare two multilevel JSON objects and determine whether they are the same.