Python: Handling Exceptions with Try/Except/Else/Finally
What is the Point? In Python, you can handle exceptions using the try/except/else/finally statements. These statements provide a way to catch and handle exceptions, execute specific code when…
Making use of the “with” statement in Python (4 examples)
What is the point? The with statement in Python provides a convenient way to manage resources, such as files, databases, or network connections, by ensuring that they are…
Shorthand syntax for if/else in Python (conditional expression)
In Python, the shorthand syntax for an if/else statement is called a conditional expression or a ternary operator. It allows you to write a concise one-liner to evaluate…
Python While Loops: Tutorial & Examples
What is the Point? The while loop in Python is a type of loop that executes a block of code repeatedly as long as a given condition is…
Python: How to Define and Call Asynchronous Functions
This concise and straight-to-the-point article shows you how to define and call an asynchronous function (async function) in Python (you’ll need Python 3.5 or higher). Defining an Async…
Python Generators: Tutorial & Examples
Overview Generators in Python are a way of creating iterators that can produce a sequence of values lazily without storing them all in memory at once. Their purpose…
Python: Handling exceptions when using async/await
This concise, straight-to-the-point article will walk you through some different ways to deal with exceptions when using async/await in Python Using try/except blocks You can use the standard…
Python async/await and timeouts (with examples)
A timeout is a limit on the amount of time that an operation can take to complete. We need it when using async/await in Python because some operations…
Python asyncio.Runner() context manager (with examples)
The Fundamentals An asyncio.Runner() context manager is a new feature in Python 3.11 that simplifies running multiple async functions in the same context. It takes care of creating…
Python Function: Keyword & Positional Arguments
This concise article is about positional and keyword arguments in Python. Positional arguments Positional arguments are arguments that are passed to a function by their position or order…