Python Iterators Explained

If you have written some Python code and used the for loop, you have already used iterators behind the scene but you probably didn’t know about it. Iterators are objects that we can iterate over one by one. They are practically everywhere in a Python code… Read more

Similar

Caching Generator Methods in Python

Each code snippet should run as a standalone example (based on Python 3.12). The standard library caching decorator functools.lru_cache has known limitations when used with instance methods. In particular, the cache is a property of the class and holds re... (more…)

Read more »

Unravelling Attribute Access in Python

I wonder how many people realize that Python is has a lot of syntactic sugar? I'm not claiming it's like a Lisp-based language where the syntax is as bare bones as possible (although the Lisp comparison is not entirely unfounded), but much of Python's syn... (more…)

Read more »