A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-March/051914.html below:

[Python-Dev] @deprecated (was: Useful thread project for 2.5?)

[Python-Dev] @deprecated (was: Useful thread project for 2.5?) [Python-Dev] @deprecated (was: Useful thread project for 2.5?)Raymond Hettinger python at rcn.com
Wed Mar 9 00:09:04 CET 2005
> Michael Chermside suggested:
>     import warnings
> 
>     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)
>         return newFunc


Decorators like this should preserve information about the underlying
function:

>     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__
          newFunc.__dict__.update(func.__dict__)
>         return newFunc


Raymond
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4