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 Slice a Dictionary in PythonIn this article, we'll explore how to slice a dictionary in Python using dictionary comprehension, list comprehension, and collections.ChainMap, and using a filter with lambda. How to Pool Map With Multiple Arguments in PythonThis tutorial demonstrates how to perform parallel execution of the function with multiple inputs using the multiprocessing module in Python. How to Write an Array to a Text File in PythonThis tutorial demonstrates how to write and save an array into a text file in Python. How to Get the Filename and a Line Number in PythonLearn how to get the filename and a line number in Python Python Except Exception as EThis tutorial discusses the difference between except and except as e statements in Python. How to Decode UTF-8 in PythonWe will learn how to decode UTF-8 in Python. How to Kill a Python ThreadThis tutorial discusses the different methods on how to kill a thread in Python. Comparators in PythonThis tutorial discusses comparators and how to implement a comparator function to sort an array in Python. How to Detect Rectangle in Python OpenCVDetect rectangles in images using OpenCV in Python. This article explores using findContours(), contourArea(), and HoughLinesP() functions for effective shape detection in computer vision. This guide offers practical code examples and insights for accurate rectangle detection. Matrix Multiplication in OpenCVThis tutorial will discuss multiplying two matrices using the asterisk operator, the multiply() function, and the gemm() function of OpenCV. How to Sample With Replacement in PythonIn this article, we will explore different methods along with example codes and explanations on how to get a sample with replacement in Python. Python Lambda With Multiple LinesWe will introduce the lambda function in Python and how to use it in multiple lines in our applications. How to Find Index of Minimum Element in a List in PythonThis tutorial discusses finding the index of the minimum element of a list in Python. How to Download CSV From URL in PythonThis tutorial discusses how to download a CSV file from URL in Python. How to Extend a Class in PythonThis article will discuss extending a Python class. We will learn the concept of inheritance in detail and the use of the super function. We will also learn how to add new methods and attributes to a child class in Python. How to Divide a List by a Number in PythonThis tutorial demonstrates how to divide a list by a number in Python. We will use loops to iterate through lists, divide each element by a specific number, and save the results into another list. How to Perform Element-Wise Addition in PythonThis tutorial demonstrates the ways on how to perform element-wise addition in Python. How to Find Maximum Float Value in PythonThis article includes two methods to find the maximum value of float data type in Python. One of them is to use the float_info.max of the sys module whereas the second way is to use the finfo() function of the numpy library. How to Solve ModuleNotFoundError: No Module Named '_Ctypes' in PythonThis tutorial demonstrates how to resolve the error titled ModuleNotFoundError: No module named '_ctypes' in Python. Python Array Value ErrorIn this article, we'll discuss the Python Array Value Error. When more than 2 on-keyword arguments are passed in the array it raises ValueError: only 2 non-keyword arguments accepted. How to Fix Function Is Not Defined Error in PythonWe will learn with this explanation what is the case when a Python program displays an error like a function not defined even though the function is present in the script. No Python Console Is Currently Selected to RunThere could be many reasons behind the no Python console being selected for run error. This blog will attempt to share the common reasons behind this error. We have also given you possible solutions to overcome the issues. How to Fix SyntaxError: Can't Assign to Literal Error in PythonThis tutorial discusses the can't assign to literal error in Python. Python Abstract PropertyOne can use the ABC module to create classes with abstract properties in Python.