Talk: Trey Hunner - Comprehensible Comprehensions

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 เม.ย. 2020
  • Presented by:
    Trey Hunner
    Finding list comprehensions incomprehensible? Having trouble figuring out when to use list comprehensions or just plain for loops? Are your coworkers overusing comprehensions?
    Come to this talk and learn the how, when, and why of list comprehensions.
    We’ll discuss:
    why list comprehensions exist and why people use them (yes you can always use a loop instead)
    how to use list, set, an dictionary comprehensions as well as generator expressions
    when and how to easily turn a for loop into a comprehension
    why list comprehensions are often hard to read and how to make your comprehensions readable
    When to use generator expressions instead of list comprehensions
    when and how not to use comprehensions (they’re not a replacement for all loops)
    Comprehensions are a unique tool for a unique task. Even if you dislike them, understanding how they work will help you better understand the Python code you find in the wild.
    You’ll leave this talk with a better appreciation for both the use cases for comprehensions in Python and an understand of when not to use them.

ความคิดเห็น • 6

  • @malteplath
    @malteplath 4 ปีที่แล้ว +7

    Excellent introduction, gentle pace, very suitable for learners of Python.

  • @Zhiltsoff
    @Zhiltsoff 4 ปีที่แล้ว

    Thanks Trey, good talk, now I'm going to go ahead and refactor all my code to use generators when I need to return sorted list from a function.

  • @ericparnell9802
    @ericparnell9802 4 ปีที่แล้ว

    Excellent talk. Thank you.

  • @davidwilder3712
    @davidwilder3712 4 ปีที่แล้ว

    Thank you sir!

  • @map-creator
    @map-creator 4 ปีที่แล้ว

    Awesome talk.

  • @privetvastutnestoyalo2339
    @privetvastutnestoyalo2339 4 ปีที่แล้ว +4

    "Looping over them right away" defeats the whole purpose of generators being lazy.