Various
Python
Transforming Code into Beautiful, Idiomatic Python
A presentation by Raymond Hettinger from PyCon 2013
03:04 -- Looping over a range of functions 04:47 -- Looping over a collection 05:28 -- Looping backwards 06:51 -- Looping over a collection of indicies 07:36 -- Looping over two collections 09:42 -- Looping in sorted order 10:04 -- Custom sort order 12:27 -- Call a function until a sentinel value 15:52 -- Distinguishing multiple exit points in loops 19:18 -- Looping over dictionary keys 21:10 -- Looping over dictionary keys and values 21:52 -- Construct a dictionary from pairs 23:15 -- Counting with dictionaries 25:30 -- Grouping with dictionaries 27:57 -- Is a dictionary pop() atomic? 29:12 -- Linking dictionaries 31:10 -- Clarify function calls with keyword arguments 32:17 -- Clarify multiple return values with named tuples 33:13 -- Unpacking sequences 34:01 -- Updating multiple state variables 36:15 -- Simultaneous state updates 38:24 -- Concatenating strings 38:41 -- Updating sequences 39:57 -- Using decorators to factor-out administrative logic 40:24 -- Caching decorator 41:19 -- Factor-out temporary contexts for decimal 42:01 -- How to open and close files 42:25 -- How to use locks 43:10 -- Factor-out temporary contexts 44:56 -- Context manager: redirect_stdout() 46:04 -- Concise expressive one-liners