~/talk

Comprehending comprehensions

Talkat PyCon US 2023 · 2023-04-19..04-27· [python]
slides:none on file

Claims that comprehensions are both essential and often misunderstood get demonstrated with concrete code: live Jupyter notebooks pushed to GitHub show list, set and dict comprehensions, nested comprehensions and generator expressions. Examples parse /etc/passwd into usernames and shells, build a list of dicts from a shoe file, and count IPs with collections.Counter; each snippet produces the promised output. The walrus operator saves repeated splits, generator expressions avoid huge in-memory lists, and the difference versus for loops (side effects vs returned collection) is made explicit.

AI-written summary · about

  1. 0:00Python comprehensions intro
  2. 4:16What are comprehensions
  3. 10:14List vs for loops
  4. 21:01List comp examples
  5. 22:26Sum numbers from input
  6. 26:46Count word lengths
  7. 29:56List comp structure
  8. 37:10Conditions in comprehensions
  9. 42:10Sum numbers from file
  10. 51:09Read files with comprehensions
  11. 1:03:12Break & Q&A
  12. 1:10:38Set comprehensions
  13. 1:20:22Dictionary comprehensions
  14. 1:31:21Dict from file exercise
  15. 1:39:02Nested list comprehensions
  16. 1:51:10Popular movie genres
  17. 1:55:09Generator expressions
  18. 2:07:30Comprehensions scoping
  19. 2:15:22Closing remarks
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.