~/talk

Comprehensible Comprehensions

Talkat PyCon AU 2017 · 2017-08-03..08-08· [python, developer-experience]
slides:none on file

Explains that list comprehensions are a concise tool for transforming one iterable into another and nothing else, shows how to copy/paste a for-loop into a comprehension, and demonstrates generator expressions (parentheses instead of brackets) as the right choice when the result is iterated only once. Covers set and dict comprehensions, using the list constructor or dict() instead of pointless comprehensions, warns against side effects like print inside comprehensions, and recommends to break comprehensions over multiple lines for readability.

AI-written summary · about

  1. 0:00Start
  2. 2:15Definitions
  3. 3:30for loops
  4. 5:46Breaking it down
  5. 6:37Copy-pasting into a comprehension
  6. 8:49Breaking up the components
  7. 15:27Generator Comprehensions
  8. 16:34Generator Expression Syntax
  9. 18:28Loop over them right away
  10. 22:20Don't abuse comprehensions
  11. 26:55Not filtering or changing anything?
~/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.