[Python-ideas] Ruby-style Blocks in Python Idea

tav tav at espians.com
Mon Mar 9 16:33:30 CET 2009

Hey Stuart,

> I believe this is just an extension to the lambda keyword. If lambdas could
> define a block, not just a statement, this would e.g. be

Multi-line lambdas would be nice, but I struggle to find a way to do
so in a Pythonic manner.

See: http://unlimitednovelty.com/2009/03/indentation-sensitivity-post-mortem.html

It would be nice to find a way though...

> tmp = lambda employee:
>    if employee.salary > developer.salary:
>       fireEmployee(employee)
>    else:
>       extendContract(employee)
> employees.select(tmp)

You might as well just use ``def`` above...

> I see no reason for introducing two new keywords to do this, as you are
> really just enhancing the current lambda keyword.

I agree that two new keywords is a bit much. I tried to re-use
``with`` initially -- but I guess people would be confused by the
conflicting semantics.

> On the other hand, turning blocks into anonymous functions would be very
> useful for functional programming. As such, I like your suggestion.

Thanks =)

love, tav

plex:espians/tav | tav at espians.com | +44 (0) 7809 569 369
http://tav.espians.com | http://twitter.com/tav | skype:tavespian

More information about the Python-ideas mailing list