Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

Timothy N. Tsvetkov timothy.tsvetkov at gmail.com
Tue Feb 23 14:09:10 EST 2010


On Feb 16, 10:41 pm, Andrej Mitrovic <andrej.mitrov... at gmail.com>
wrote:
> On Feb 16, 7:38 pm, Casey Hawthorne <caseyhHAMMER_T... at istar.ca>
> wrote:
>
> > Interesting talk on Python vs. Ruby and how he would like Python to
> > have just a bit more syntactic flexibility.
>
> >http://blog.extracheese.org/2010/02/python-vs-ruby-a-battle-to-the-de...
> > --
> > Regards,
> > Casey
>
> Gary's friend Geoffrey Grosenbach says in his blog post (which Gary
> linked to): "Python has no comparable equivalent to Ruby’s do end
> block. Python lambdas are limited to one line and can’t contain
> statements (for, if, def, etc.). Which leaves me wondering, what’s the
> point?"
>
> I'm sorry, lambda's do support if's and for's. Also, lambda's are
> expressions, not statements, but you can pass them around, keep them
> in a dictionary if you want to. And if you need more than one line of
> statements, for crying out loud use a def? And who needs those "do-
> end" blocks anyway, trying to turn Python into Pascal?

I think there are some nice use-cases for anonymous functions /
blocks. First, mentioned above, is pretty DSL. And the second is using
blocks in map/reduce functions. Yes, you can pass there a function but
I believe that in most situations it is more readable to pass a
multiline anonymous function / block than defined somewhere function
written only for a single map/reduce operation. And often when you use
reduce it is a bit more complicated then just one line function.



More information about the Python-list mailing list