On Tue, Mar 10, 2009 at 10:13 AM, Calvin Spealman <ironfroggy@gmail.com> wrote:
On Mon, Mar 9, 2009 at 12:39 PM, Guido van Rossum <guido@python.org> wrote:
On Mon, Mar 9, 2009 at 6:04 AM, tav <tav@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:
@using(employees.select) def _(employee): if employee.salary > developer.salary: fireEmployee(employee) else: extendContract(employee)
What would `using` here do that decorating the temp function with employees.select itself wouldn't do? All you are doing is saying "Pass this function to this function" which is exactly what decorators already do.
I think the original proposal was implying some kind of loop over the values returned by employees.select(). But it's really irrelevant for the equivalency. -- --Guido van Rossum (home page: http://www.python.org/~guido/)