generators

Tutorials on Python generators and the yield keyword for producing values one at a time.

NumPy: Array Creation with zeros, ones, arange, linspace

NumPy arrays are the building blocks of almost every data science and machine learning task in Python. This guide is your quick reference for creating one: zeros, ones, arange, linspace, eye, full, empty, the modern random generator, plus indexing basics, with tested output for every single method. “The art of programming is the art of organizing complexity.” Edsger Dijkstra Last Updated: July 2026 | Tested on: Python 3.14.6, NumPy 2.4.6 | Difficulty: Intermediate | Reading Time: 22 minutes NumPy hands ... Read More

Python: Advanced Comprehensions, Nested, Generator Expressions, Performance

Take your Python comprehension skills past the basics. You will master nested comprehensions for multi-dimensional data, generator expressions for memory-efficient pipelines, and the performance facts that decide when a comprehension wins and when a plain for loop is the smarter choice. “Flat is better than nested.” Tim Peters, PEP 20 Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Intermediate | Reading Time: 17 minutes You already know the basic python comprehension. Something like [x * 2 for ... Read More

Python: Iterators and the Iterator Protocol

Ask Python to loop over a list, a file, or a dictionary, and it plays the same trick every time: it asks the object for a Python iterator, then pulls values one by one until StopIteration says stop. This post unpacks that protocol, __iter__ and __next__ included, and shows you how to build a custom iterator of your own. “Simple is better than complex. Complex is better than complicated.” Tim Peters, The Zen of Python (PEP 20) Last Updated: July ... Read More