3 ms·
Python actually does this right for sequence comprehensions: >>> [f() for f in (lambda: x for x in range(10))] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] List compr
by int_19h 4y ago
Python actually does this right for sequence comprehensions:
>>> [f() for f in (lambda: x for x in range(10))]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
List comprehensions have been around for longer, and so behave the way they do for backwards compatibility reasons.