Earlier quoted context omitted.
I used Python for a really long time and switched to Ruby several months ago. Benefits of Ruby are: -no distinction between expression and statement (everything has a value) -lambdas can thus contain any expression -much bigger range of built-in methods and classes (all permutations of a list, removing duplicates from a list, Rational class, Regexp class, Range class, etc.) -more flexible syntax and "control operator…
> -lambdas can thus contain any expression why would you want to use lambdas if you have generator expressions? eg: map(lambda c: c.strip(), countries.split(',')) vs [c.strip() for c in countries.split(',')] 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…
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 (He didn't, thankfully. I still want reduce back in 3.x, though.)