How I write Python
- One library for both sync and async
- Easy to use a SOCKS proxy
- Similar to requests but typed
- Faster than Beautiful Soup with html5-parser or html5lib
- Easier to install than html5-parser. Doesn’t require disabling binary wheels for lxml.
- The API design helps type safety
- Complies with the CommonMark standard
- Typed
- Faster than other CommonMark libraries in pure Python
- Correctly handles DST
- Uses types to prevent mistakes
See “Ten Python datetime pitfalls, and what libraries are (not) doing about it”, Arie Bovenberg2024.
yarl.
- Percent-decodes paths
-
Nice API:
- Fields are named well
- Query parameters are stored in a
MultiDict
- More fun than any other XML library
- Parses and generates XML. (Despite the name, xmltodict is bidirectional.)
Python has robust optional static typing. If you took a break from Python in the mid-2010s like I did, it may come as a surprise. This page links to resources for writing statically-typed Python, plus a few that make use of type hints at runtime.
- “Deploying a distributed system? A type system helps a lot”, Spencer Baugh2021.
- “Algebraic Data Types in (typed) Python”, Tin Tvrtković2023
- “Writing Python like it’s Rust”, Jakub Beránek2023. The author’s style resembles the style I have arrived it.
- “Shape typing in Python”, Jim Fisher2024
- jsonargparse—“Implement minimal boilerplate CLIs derived from type hints and parse from command line, config files and environment variables”
- Typed Argument Parser (Tap)—“Typed argument parser for Python”
- Typer—“Typer, build great CLIs. Easy to code. Based on Python type hints.”
- tyro—“Zero-effort CLI interfaces & config objects, from types”
- poltergeist—“Rust-like error handling in Python, with type-safety in mind.”
- Python type checkers—my GitHub list
- “Awesome Python Typing”—a collection of links to software and articles