Skip to Content
0 likes
Python Decorators Explained With One Real Example Level: Advanced

A decorator is just a function that wraps another function. Build a real timing decorator step by step: functions as values, the wrapper, the @ syntax, and functools.wraps. After that, the syntax stops looking like magic.

0 likes
Python Generators: Handle Big Files Without Running Out of Memory Level: Advanced

Reading a big file into a list can kill your program. A generator handles one line at a time. See the memory difference measured on a real file, learn what yield does, and chain small generators into a pipeline.

0 likes
Python Closures: Building a Counter Without a Global Variable Level: Advanced

A closure remembers variables from the function that created it. Build separate counters with no globals, fix the UnboundLocalError with nonlocal, avoid the lambda-in-a-loop trap, and know when a class is clearer.

0 likes
Writing a Custom Iterator Class in Python With __iter__ and __next__ Level: Advanced

A for loop calls iter() once and next() until StopIteration. Write __iter__ and __next__ yourself, avoid the iterator that only works once, and know when a generator in __iter__ does the same job in fewer lines.

0 likes
Writing Your Own Python Context Manager, With a Class or contextlib Level: Advanced

Write a context manager when something must be undone no matter how the block ends. Build one as a class and with @contextmanager, keep yield inside try/finally, and don't swallow errors by accident.

0 likes
Closures for Private State: A Counter You Can't Break Level: Advanced

Keep a counter's value in a closure so nothing outside can set it to -5 or "abc". The pattern, how it compares with a class with

0 likes
Fix a Bound Event Listener That Will Not Detach Level: Advanced

Trace a wrong callback receiver, bind one stable listener, and verify start, stop and restart without duplicate or stale subscriptions.

0 likes
Predict the Output: Event Loop Order in 6 Snippets Level: Advanced

Six short snippets with setTimeout, promises, await and queueMicrotask. Predict the order, run it, then read why. The one rule: sync code first, then all microtasks, then the next task.

0 likes
Batch API Calls With Promise.allSettled Level: Advanced

Send many requests, keep the successes, and report the failures instead of losing everything to one rejected promise. Plus limiting how many run at once.

0 likes
Paginate an API With an Async Generator Level: Advanced

Hide page numbers and "next" links inside an async generator, then loop over every record with for await. Stop early and the remaining pages are never fetched.