"inhahe" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> 4. can someone tell me if the way i'm using the decorator is sane? i've
> never used decorators before. it just seems ridiculous to a) define a
> lambda that just throws away the parameter, and b) define a meaningless
> function to pass to that lambda.
>
I thought about the fact that a decorator is merely syntactic sugar, so it
shouldn't have any closure magic that I can't make myself, and I realized
that I could have done it the following way:
def makefunc(func):
def func2(instance, *args):
result = func(instance, *args)
instance.save()
return result
return func2
for name, func in deque.__dict__.items():
if (not name.startswith("_")) or name in ('__delitem__', '__setitem__'):
setattr(pdeque, name, makefunc(func))
--
http://mail.python.org/mailman/listinfo/python-list