decorator J4 - any objections?

Paul Morrow pm_mon at
Sat Aug 21 04:22:42 CEST 2004

Paul Rubin wrote:

> Jeffrey Froman <Jeffrey at> writes:
>>>   def func(arg1, arg2)
>>>       @version("Added in 2.4")
>>>       @returns(None)
>>>   as:
>>>       """Docstring could be here, or in decorator part above"""
>>>       # body goes here
>>I like this better than the current proposal because it reads from top to
>>bottom, and flows like a typical conditional.
>>Before function writing the decorators whereas like reads this.
> J4 is my favorite of the enumerated proposals I remember, so I'll
> "vote" for it, but I still think something better should be possible.

It seems to me that we've had decorators all along (if we expand the 
definition a little), for example __metaclass__ sure looks like a class 
decorator.  So how about...

     def func(arg1, arg2):
         """Docstring goes here, as normal."""
         __version__ = 'Added in 2.4'
         __returns__ = None
         # function body goes here

     def returns(func, *args):
         """Docstring for 'returns' decorator."""
         __decorator__ = True
         # body of decorator goes here

More information about the Python-list mailing list