Python Tips, Tricks, and Idioms
summary
A fast tour of concrete Python tips: use \N{...} for readable Unicode literals, copy lists with [:], and read files in fixed chunks with iter(f.read, '') instead of while loops; sort by multiple keys using stable sort via two-pass (secondary key first), and replace list insert(0)/pop(0) with deque for O(1) pop(0) to fix scalability. Covers enumerate/zip for lock‑step iteration, else on for-loops as “not found” after break, key functions and itemgetter, iterators/generators, defaultdict/Counter/OrderedDict, and a dict‑sparsify trick for internal resizing.
AI-written summary · about
chapters (7)
- 0:00Start
- 5:31Negative Slicing
- 10:52Basics
- 14:15Lockstep Iteration
- 17:56Reason Not To Use an Else in the Absence of a Break
- 19:01Complex Numbers
- 43:20Dictionary Is Missing Method
related talks
29mI wish I learnt that earlier!
46mOn Being Pythonic
19mPython - best practices
40mA Few Python Tips
43mPython Improvements (or This Is Not Your Teacher's Python)
43mWriting Idiomatic Python
01h 12mFurious & Fast Python 7: Writing Fast Python Code
24mPython for Humans, Designing Python Code Like a User Interface
