News for hackers. Stuff that matters.
Re:Python Is Eating the World by ptx on Monday August 12, 2019 @03:32AM (#20673279)
If by generic you mean able to use other types of collections, aren't generator expressions[1] the generic version of list comprehensions?

List comprehension:

  a = [x for x in stuff if x > 1]
Equivalent generic version:

  a = list(x for x in stuff if x > 1)
With your own collection type:

  a = MyCustomCollection(x for x in stuff if x > 1)
[1] https://www.python.org/dev/peps/pep-0289/

There are no comments on this comment yet.