Python
Shell Out Safely: A Practical Deep Dive into Python's subprocess
Learn to run external commands from Python the right way: subprocess.run, capturing output, timeouts, error handling, piping input, and avoiding the shell-injection trap.
Python
Learn to run external commands from Python the right way: subprocess.run, capturing output, timeouts, error handling, piping input, and avoiding the shell-injection trap.
Python
Go beyond bare try/except: learn EAFP, the else and finally clauses, custom exception hierarchies, exception chaining with `raise from`, contextlib.suppress, and Python 3.11's ExceptionGroup and except* for handling multiple failures at once.
Python
Magic numbers and bare strings quietly rot codebases. Learn how Python's enum module gives you readable, type-safe, self-documenting constants — from basic Enum and auto() to IntEnum, Flag bitmasks, StrEnum, methods on members, and the aliasing pitfalls that trip people up.
Python
Learn to parallelize Python with concurrent.futures: when to reach for threads vs. processes, how submit(), map(), and as_completed() work, handling errors and timeouts, and the pitfalls that bite people in production.
Python
Naive vs. aware datetimes, correct time-zone handling with the standard-library zoneinfo module, DST gotchas, safe parsing and formatting, and why arithmetic across a DST boundary can quietly lose an hour.
Python
Go beyond assert True. Learn how pytest's plain assertions, fixtures, parametrization, built-in helpers like tmp_path and monkeypatch, and markers combine into a fast, readable test suite — with runnable examples and the pitfalls to avoid.
News
A quieter week after early August's releases: Astral shipped a breaking uv 0.10 with stable Python version management, Python 3.15 heads into its final release candidates (final due Oct 1), the PSF named 17 candidates for the inaugural Packaging Council, and Polars kept pushing on performance.
Python tutorials that go beyond the basics - deep dives into the standard library, testing, typing, and async, plus weekly Python news.
Learn how to write fast, isolated tests with Python's unittest.mock — Mock vs MagicMock, return_value and side_effect, the patch() decorator, the "patch where it's used" rule, autospec, and mocking files and properties.
Learn how Python's asyncio runs thousands of I/O operations concurrently on a single thread. Master async/await, tasks, gather, TaskGroup, timeouts, semaphores, and the pitfalls that trip everyone up.
Python's built-in list and dict get you far, but the collections module offers Counter, defaultdict, namedtuple and deque — specialized containers that make everyday code shorter, faster, and clearer.
Learn how Python decorators really work — from the closure underneath to functools.wraps, decorators that take arguments, class-based decorators, stacking, and the pitfalls that bite people in production.
Learn to build polished command-line tools with Python's argparse — positional and optional arguments, types, choices, nargs, count/append actions, mutually exclusive groups, subcommands, and the pitfalls that trip people up.
Learn how to use Python's type hints for real — from Optional and unions to TypedDict, Protocol, generics, and Literal — plus the pitfalls that trip people up and how to run mypy.
Learn how Python's logging module really works — loggers, handlers, formatters, levels, and propagation — plus dictConfig setup, structured JSON logs, rotating files, and the pitfalls that trip up almost everyone.
Learn how Python's functools module helps you cache expensive calls, freeze arguments, dispatch on type, and write decorators that behave — with runnable examples and the pitfalls to avoid.
This week in Python: Django 6.1 ships alongside a GeoDjango security fix, CPython 3.14.7 lands, MCP goes stateless and renames FastMCP to MCPServer, Python 3.15 hits release candidates, and Packaging Council nominations close August 12.
Learn how Python's itertools builds fast, memory-efficient pipelines from small iterator building blocks — count, chain, groupby, accumulate, product, and battle-tested recipes like sliding windows and batching.
Learn how Python's with statement really works — from writing your own context managers to using contextlib's contextmanager, suppress, redirect_stdout, closing, and ExitStack to write cleaner, leak-free resource-handling code.
Structural pattern matching turns tangled if/elif chains into readable, declarative code. Here's when to reach for match — and when a plain dictionary is still the better call.