decorator J4 - any objections?

Christophe Cavalaria chris.cavalaria at free.fr
Fri Aug 20 20:26:42 EDT 2004


Larry Bates wrote:

> If docstring can be a special case of a triple quoted
> string, I don't see why decorators couldn't be a special
> case of a dictionary.
> 
> def func(arg1, arg2):
>     {'version': 'Added in 2.4',
>      'returns': None,
>      'docstring': 'Docstring could be here, or in decorator part above'}
>      """Docstring could be here, or in decorator part above"""
> 
> or perhaps:
> 
> 
> def func(arg1, arg2):
>     #
>     # Similiar to class __dict__
>     #
>     __decorators__=__{'version': 'Added in 2.4',
>                       'returns': None,
>                       'docstring': 'Docstring could be here, or in
>                       decorator
> part above'}
>     """Docstring could be here, or in decorator part above"""
> 
> 
> I'm sure there is a reason, but it would seem to make
> "Python"-sense to me.  It would then be very extensible
> for the meta-data that everyone seems to also want decorators
> to support.

Maybe because decorators aren't just function properties but functions that
transform the function they receive in parameter. Therefore, that proposal
doesn't solve the problem at hand. It's a bad solution.

How would you do the staticmethod ou the memoize with that proposal ?




More information about the Python-list mailing list