Python

Python: Handling Exceptions with Try/Except/Else/Finally

Updated: July 15, 2023 By: Wolf

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)

Updated: July 15, 2023 By: Wolf

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)

Updated: July 15, 2023 By: Khue

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

Updated: July 15, 2023 By: Khue

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

Updated: July 13, 2023 By: Wolf

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

Updated: July 13, 2023 By: Goodman

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

Updated: July 12, 2023 By: Khue

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)

Updated: July 12, 2023 By: Wolf

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)

Updated: July 11, 2023 By: Khue

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

Updated: July 15, 2023 By: Wolf

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…

1 48 49 50 51 52 64