> 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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com