2 ms·
>Range class: [i for i in range(10)] How does this differ from list(range(10)) (besides being highly suggestive of the power of list comprehensions)? >IMHO th
by wging 15y ago
>Range class: [i for i in range(10)]
How does this differ from list(range(10)) (besides being highly suggestive of the power of list comprehensions)?
>IMHO the latter one is way more readable and generators cover almost all the use cases for lambdas. If you could not do it with a generator expression and choose to use a anonymous function it should have been a method anyway.
This is actually why Guido van Rossum wanted to remove lambda from the core language: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 http://www.artima.com/weblogs/viewpost.jsp?thread=98196 (He didn't, thankfully. I still want reduce back in 3.x, though.)