3 ms·
Thanks for pointing that out. I would have guessed that the original form would desugar to map(lambda i: (lambda: i), xrange(10)) but apparently it doesn't.
by sbi 15y ago
Thanks for pointing that out. I would have guessed that the original form would desugar to
map(lambda i: (lambda: i), xrange(10))
but apparently it doesn't.
- ot 15y agoExactly, it desugars to something like a for loop, in fact the iteration variable remains visible in the outer scope (other possible source of confusion). I believe it doesn't desugar to a map+lambda for performance reasons.
- baq 15y agoif it desugared to map, you could redefine map() and unleash all kinds of hell on yourself inadvertently.