[Python-ideas] Ruby-style Blocks in Python Idea
Joel Bender
jjb5 at cornell.edu
Tue Mar 10 15:56:01 CET 2009
Guido van Rossum wrote:
> @using(employees.select)
> def _(employee):
> if employee.salary > developer.salary:
> fireEmployee(employee)
> else:
> extendContract(employee)
I personally don't mind anonymous functions, I use them when I can fit
everything on mostly one line and they don't have any side effects.
None of my decorators that I write actually call the function they are
passed either.
So there could be a lambda statement...
@using(employees.select)
lambda employee:
if employee.developer and employee.not_using_python:
fireDeveloper(employee)
...which would make a function that isn't named, purely for its side
effects.
-$0.02
Joel
More information about the Python-ideas
mailing list