stdlib

Guides to the Python standard library and its most useful built-in modules.

Python: Regex in Practice (Validation, Parsing, Text Processing)

These python regex examples put regular expressions to work on real jobs: validate emails, phone numbers, and passwords, parse log files and CSV (comma-separated values) data, pull clean information out of messy text, and wire it all into a small text processing pipeline. Every pattern here is tested and ready to paste into your own code. “Some people, when faced with a problem, think: I know, I will use regular expressions. Now they have two problems. Use the right tool, ... Read More

Python: Closures, Lexical Scoping & Practical Uses

A Python closure is a function that remembers variables from its enclosing scope even after that scope is gone. This post shows how that memory works under the hood: lexical scoping, cell objects, the nonlocal keyword, and why every decorator you will ever write is built on a closure. “The key to understanding complicated things is knowing what not to look at.” Peter Norvig, PAIP Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Intermediate | Reading Time: ... Read More

Python: Decorators Deep Dive, Writing & Real-World Patterns

Python decorators explained from the ground up: how the @ symbol wraps and replaces your function, how to write decorators that take arguments, why you always reach for functools.wraps, and the real-world patterns you will actually use, like timing, retry, and caching. “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” Martin Fowler, Refactoring Last Updated: July 2026 | Tested on: Python 3.14.6 | Difficulty: Intermediate | Reading Time: 17 minutes ... Read More