ordered keywords?
Ron Adam
rrr at ronadam.com
Mon Oct 17 19:09:58 EDT 2005
Ron Adam wrote:
>
> def lamb(args):
> for v in args: print v
>
> def feedlamb():
> print locals()
> y = 20
> lamb( (lambda x=10: (x,y,x+y))() )
> print locals()
>
> feedlamb()
>
> {}
> 10
> 20
> 30
> {'y': 20}
>
>
> Cool, this is the exact behavior I was thinking of, but without the
> lambda if possible, and without all the extra parentheses. Anyway to
> clean this up?
>
> Maybe it wouldn't be as big a change as it seems? ;-)
>
> Cheers,
> Ron
Ok, this has a problem, there's no way to pass the values as keywords
also. The lambda's a bit too isolated. So the following doesn't work as
expected.
lamb( (lambda x=10: (x,y,x+y,{'x':x}))() )
Regards,
Ron
More information about the Python-list
mailing list