[Python-Dev] Re: @deprecated (was: Useful thread project for 2.5?)
reinhold-birkenfeld-nospam at wolke7.net
Fri Mar 11 17:23:43 CET 2005
Nick Coghlan wrote:
> Raymond Hettinger wrote:
>> Decorators like this should preserve information about the underlying
>>> def deprecated(func):
>>> """This is a decorator which can be used to mark functions
>>> as deprecated. It will result in a warning being emmitted
>>> when the function is used."""
>>> def newFunc(*args, **kwargs):
>>> warnings.warn("Call to deprecated function.")
>>> return func(*args, **kwargs)
>> newFunc.__name__ = func.__name__
>> newFunc.__doc__ = func.__doc__
>>> return newFunc
> A utility method on function objects could simplify this:
+1. This is really good for 90% of all decorator uses. But maybe a
better name should be found, perhaps "update_meta".
Mail address is perfectly valid!
More information about the Python-Dev