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.
Explore Python, one of the most popular and versatile programming languages, renowned for its readability, efficiency, and vast ecosystem of libraries. This tag covers Python basics, advanced features, data science applications, web development with Django and Flask, and the language's role in artificial intelligence and machine learning projects.
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
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.
Python
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
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.
Python
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.
Python
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.