Multi-line lambda proposal.

Duncan Booth duncan.booth at invalid.invalid
Thu May 11 05:02:34 EDT 2006


yairchu at gmail.com wrote:

> this is how I think it should be done with multi-line lambdas:
> 
> def arg_range(inf, sup, f):
>   return lambda(arg):
>     if inf <= arg <= sup:
>       return f(arg)
>     else:
>       raise ValueError
> 
> and instead of
> @arg_range(5, 17)
> def f(arg):
>   return arg*2
> 
> you do:
> f = arg_range(5, 17, lambda(arg)):
>   return arg*2
> 
> 
One big problem with this is that with the decorator the function has a 
name but with a lambda you have anonymous functions so your tracebacks are 
really going to suck.



More information about the Python-list mailing list