Skip to main content

Python

2026


What does yield do in Python, and what happens when I call the function?

7 mins
Python generators allow you to iterate over data efficiently using the yield keyword. They are not only memory-efficient but also enable lazy evaluation, making them ideal for handling large datasets or infinite sequences. However, many beginners find generators confusing due to their unique behavior compared to regular functions and lists.

An Introduction to Python's Dataclass Decorator

5 mins
Python's @dataclass (introduced in Python 3.7) is a decorator that automatically generates boilerplate methods for classes that primarily store data. It simplifies class creation; no need to manually write `__init__`, `__repr__`, etc.

2025


Python JSON Tips, Tricks, and Pitfalls

7 mins
Working with JSON in Python seems straightforward — the built‑in json module can load data from a file and dump Python objects back to disk. Many new developers, however, run into confusing errors, odd behaviour or inefficient patterns when handling real‑world JSON.

What is the __pycache__ folder in Python?

3 mins
The __pycache__ folder in Python is where the interpreter stores compiled bytecode files to optimize program execution. But what exactly does that mean, and why is it important?

Why Do Python Scripts Use if __name__ == "__main__"?

4 mins
Have you ever written a Python script, run it successfully, and then imported it into another program only to watch it behave strangely? Maybe it printed a prompt you didn’t expect or started an expensive computation as soon as you imported it.