[Python-Dev] Ruby-style Blocks in Python [Pseudo-PEP]

tav tav at espians.com
Sun Mar 8 16:13:01 CET 2009

Hey all,

Apologies for bringing up an old issue, but I think I've worked out a
Pythonic syntax for doing Ruby-style blocks. The short of it is:

    with employees.select do (emp):
        if emp.salary > developer.salary:
            return fireEmployee(emp)
            return extendContract(emp)

I explain in detail in this blog article:


It covers everything from why these are useful to a proposal of how
the new ``do`` statement and __do__ function could work.

Let me know what you think.

My apologies if I've missed something obvious. 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-Dev mailing list