title: How to warn about class (name) deprecation
body: <p>I have renamed a python class that is part of a library. I am willing to leave a possibility to use its previous name for some time but would like to warn user that it's deprecated and will be removed in the future.</p>
  
  <p>I think that to provide backward compatibility it will be enough to use an alias like that:</p>
  
  <pre><code>class NewClsName:
      pass
  
  OldClsName = NewClsName
  </code></pre>
  
  <p>I have no idea how to mark the <code>OldClsName</code> as deprecated in an elegant way. Maybe I could make <code>OldClsName</code> a function which emits a warning (to logs) and constructs the <code>NewClsName</code> object from its parameters (using <code>*args</code> and <code>**kvargs</code>) but it doesn't seem elegant enough (or maybe it is?).</p>
  
  <p>However, I don't know how Python standard library deprecation warnings work. I imagine that there may be some nice magic to deal with deprecation, e.g. allowing treating it as errors or silencing depending on some interpreter's command line option.</p>
  
  <p>The question is: How to warn users about using an obsolete class alias (or obsolete class in general).</p>
  
  <p><strong>EDIT</strong>: The function approach doesn't work for me (I already gave it a try) because the class has some class methods (factory methods) which can't be called when the <code>OldClsName</code> is defined as a function. Following code won't work:</p>
  
  <pre><code>class NewClsName(object):
      @classmethod
      def CreateVariant1( cls, ... ):
          pass
  
      @classmethod
      def CreateVariant2( cls, ... ):
          pass
  
  def OldClsName(*args, **kwargs):
      warnings.warn("The 'OldClsName' class was renamed [...]",
                    DeprecationWarning )
      return NewClsName(*args, **kwargs)
  
  OldClsName.CreateVariant1( ... )
  </code></pre>
  
  <p>Because of:</p>
  
  <pre><code>AttributeError: 'function' object has no attribute 'CreateVariant1'
  </code></pre>
  
  <p>Is inheritance my only option? To be honest, it doesn't look very clean to me - it affects class hierarchy through introduction of unnecessary derivation. Additionally, <code>OldClsName is not NewClsName</code> what is not an issue in most cases but may be a problem in case of poorly written code using the library.</p>
  
  <p>I could also create a dummy, unrelated <code>OldClsName</code> class and implement a constructor as well as wrappers for all class methods in it, but it is even worse solution, in my opinion.</p>