[Python-Dev] PEP 318: Let's propose some useful built-in decorators

Guido van Rossum guido at python.org
Fri Apr 2 15:08:03 EST 2004

> >  class func_attrs(objects):
> >
> >      def __init__(self, **kwds):
> >          self.attrs = kwds
> >
> >      def __call__(self, funcobj):
> >          funcobj.__dict__.update(self.attrs)
> >
> Did you leave out the 'return funcobj' from the end of __call__?  I
> thought that decorators were supposed to be inherently cooperative,
> and should return their modified funcobj, or a new func-like-obj.

Sorry, you're right.  (I've been thinking of interpreting a None
result as "keep the input object" but the code generation would be too

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list