Python Async Await: Mastering Concurrent Programming

Python’s async and await are powerful features that enable you to write asynchronous code to improve the performance of your applications, particularly when dealing with I/O-bound and high-level structured network code. Async and await are used with coroutines, which are special functions that can pause and resume their execution at specific points. This allows multiple … Read more

How to Return Multiple Values from a Function in Python

Understanding Functions in Python πŸ’‘ A Python function is a block of reusable code that performs a specific task. Functions help break your code into smaller, more modular and manageable pieces, which improves readability and maintainability. Python functions are defined using the def keyword, followed by the function’s name and a pair of parentheses containing … Read more

“is” vs “==” Python Identity and Equality

πŸ’¬ Question: What is the difference between Python’s is and == operators? Answer The Python “==” operator compares equality of values whereas the Python “is” operator compares identity of objects, i.e., do the two operands point to the same object in memory. For example, the expression [1, 2, 3] == [1, 2, 3] returns True … Read more

Python Return Error From Function

Problem Formulation πŸ’¬ Question: How do you write a function that returns a real Python error instead of an “error code” such as -1 or None in case something got wrong? For example, you may want to check the function input arguments for having the correct type or length (in the case of iterable arguments) … Read more

Python Programming Tutorial [+Cheat Sheets]

(Reading time: 19 minutes) The purpose of this article is to help you refresh your knowledge of all the basic Python keywords, data structures, and fundamentals. I wrote it for the intermediate Python programmer who wants to reach the next level of programming expertise. The way of achieving an expert level is through studying the … Read more

Python foreach Loop

πŸ’‘ Question: Does Python have a for each or foreach loop? If so, how does it work? If not, what is the alternative? This article will shed light on these questions. I’ll give you the summary first and dive into the details later: Python has three alternatives to the “for each” loop: A simple for … Read more