def deprecated_method(replacement):
 def outer(fun):
  msg = ('%s() is deprecated; use %s() instead' % (fun.__name__, replacement))
  if (fun.__doc__ is None):
   fun.__doc__ = msg
  @functools.wraps(fun)
  def inner(self, *args, **kwargs):
   warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
   return getattr(self, replacement)(*args, **kwargs)
  return inner
 return outer

def deprecated_method ( replacement ) : def outer ( fun ) : msg = ( '%s() is deprecated; use %s() instead' % ( fun . __name__ , replacement ) ) if ( fun . __doc__ is None ) : fun . __doc__ = msg @ functools . wraps ( fun ) def inner ( self , * args , ** kwargs ) : warnings . warn ( msg , category = DeprecationWarning , stacklevel = 2 ) return getattr ( self , replacement ) ( * args , ** kwargs ) return inner return outer
a decorator which can be used to mark a method as deprecated replcement is the method name which will be called instead .