Welcome, guest | Sign In | My Account | Store | Cart
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 %s." % func.__name__,
        return func(*args, **kwargs)
    newFunc.__name__ = func.__name__
    newFunc.__doc__ = func.__doc__
    return newFunc

# === Examples of use ===

def some_old_function(x,y):
    return x + y

class SomeClass:
    def some_old_method(self, x,y):
        return x + y