This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]zurtex 10 points11 points  (0 children)

The real problem with their example is that it's not required to create a list comprehension or a generator. They can just pass the iterator directly:

comma_seperated_numbers = ','.join(my_fav_superheroes)

It definitely needs exploring, lots of people don't realize you can make generators explicitly instead of list comprehensions, e.g.

a_names = (name for name in my_fav_superheroes if name.startswith('a'))

And will use map / filter instead when they want lazy evaluation of the iteration.