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

Guido van Rossum guido at python.org
Mon Mar 9 17:39:30 CET 2009

On Mon, Mar 9, 2009 at 6:04 AM, tav <tav at espians.com> wrote:
> I've come up with a way to do Ruby-style blocks in what I feel to be a
> Pythonic way:
>  using employees.select do (employee):
>      if employee.salary > developer.salary:
>          fireEmployee(employee)
>      else:
>          extendContract(employee)

Sounds like you might as well write a decorator named @using:

 def _(employee):
     if employee.salary > developer.salary:

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-ideas mailing list