[Python-ideas] variable binding [was lambda decorators]
Adam Olsen
rhamph at gmail.com
Tue Feb 10 02:36:29 CET 2009
Of course a much simpler decorator is possible:
for i in range(10):
@bind(i=i)
def my_func(i):
print i
# Implementing bind is left as an exercise for the reader
i is passed to bind as a keyword argument, which it saves and later
passes to my_func as a keyword argument. No default values are used
so it's no longer considered "ugly". It will also give an error if
somebody accidentally passes in i themselves.
I stand by my previous comment on it not being worthwhile.
--
Adam Olsen, aka Rhamphoryncus
More information about the Python-ideas
mailing list