Python 3.12 Preview: Static Typing Improvements – Real Python
In this tutorial, you'll preview the new static typing features in Python 3.12. You'll learn about the new syntax for type variables, making generics simpler to define. You'll also see how @override lets you model inheritance and how you use typed dictionaries to annotate variable keyword arguments.
Python's Built-in Functions: A Complete Exploration – Real Python
In this tutorial, you'll learn the basics of working with Python's numerous built-in functions. You'll explore how to use these predefined functions to perform common tasks and operations, such as mathematical calculations, data type conversions, and string manipulations.
Understanding the Python Mock Object Library – Real Python
In this tutorial, you'll learn how to use the Python mock object library, unittest.mock, to create and use mock objects to improve your tests. Obstacles like complex logic and unpredictable dependencies make writing valuable tests difficult, but unittest.mock can help you overcome these obstacles.
What Is the __pycache__ Folder in Python? – Real Python
In this tutorial, you'll explore Python's __pycache__ folder. You'll learn about when and why the interpreter creates these folders, and you'll customize their default behavior. Finally, you'll take a look under the hood of the cached .pyc files.
Python's logging module isn't the only way to create logs. There are several third-party packages you can use, too. One of the most popular is Loguru. Loguru intends to remove all the boilerplate you get with the Python logging API. You will find that Loguru greatly simplifies creating logs in Python.
Python Sequences: A Comprehensive Guide – Real Python
This tutorial dives into Python sequences, which is one of the main categories of data types. You'll learn about the properties that make an object a sequence and how to create user-defined sequences.
This tutorial explores lazy evaluation in Python and looks at the advantages and disadvantages of using lazy and eager evaluation methods. By the end of this tutorial, you'll clearly understand which approach is best for you, depending on your needs.
Pydantic: Simplifying Data Validation in Python – Real Python
Discover the power of Pydantic, Python's most popular data parsing, validation, and serialization library. In this hands-on tutorial, you'll learn how to make your code more robust, trustworthy, and easier to debug with Pydantic.
How to Catch Multiple Exceptions in Python – Real Python
In this how-to tutorial, you'll learn different ways of catching multiple Python exceptions. You'll review the standard way of using a tuple in the except clause, but also expand your knowledge by exploring some other techniques, such as suppressing exceptions and using exception groups.
How to Download Files From URLs With Python – Real Python
In this tutorial, you'll find the right tools to help you download files from URLs with Python and manage the data retrieval process. You'll cover data streaming, thread pools, and asynchronous downloads.
Merge multiple dictionaries and add items to a dictionary in Python | note.nkmk.me
This article explains how to add a new item to a dictionary (dict) or update the value of an existing item in Python. It is also possible to merge multiple dictionaries.Add or update an item in the dictionary by specifying a key Merge multiple dictionaries: update(), {}, dict(), |, |= Add or update ...
Iterators and Iterables in Python: Run Efficient Iterations – Real Python
In this tutorial, you'll learn what iterators and iterables are in Python. You'll learn how they differ and when to use them in your code. You'll also learn how to create your own iterators and iterables to make data processing more efficient.
Data classes are one of the new features of Python 3.7. With data classes you do not have to write boilerplate code to get proper initialization, representation and comparisons for your objects.
How to Split a Python List or Iterable Into Chunks – Real Python
This tutorial provides an overview of how to split a Python list into chunks. You'll learn several ways of breaking a list into smaller pieces using the standard library, third-party libraries, and custom code. You'll also split multidimensional data to synthesize an image with parallel processing.
Logging is one of the best ways to keep track of what is going on inside your code while it is running. Python comes with a very powerful logging library but with great power… things start to get a bit complicated.