title: NameError: name of the class not defined inside the class itself - python
body: <p>I have the following code:</p>
  <pre><code>import numpy as np
  
  class ClassProperty(property):
      def __get__(self, cls, owner):
          return self.fget.__get__(None, owner)()
  
  def coord(cls, c):
      if cls.dimension &lt;= 2:
          return c
      else:
          return c + [0]*(cls.dimension-2)
  
  class Basis_NonI(object):
  
      @ClassProperty
      @classmethod
      def zerocoord(cls):
          return coord(cls, [0,0])   
          
      def __init__(self, dimension):
          pass
  
  class Basis_D(Basis_NonI):
      dimension = 2
      proj_matrix = np.array([Basis_D.zerocoord, Basis_D.zerocoord])
      def __init__(self, dimension):
          super(Basis_D, self).__init__(Basis_D.dimension)
  </code></pre>
  <p>where basically I want <code>dimension</code> and <code>proj_matrix</code>to be class attributes of <code>Basis_D</code>.</p>
  <p>When I run it, the following error is given:</p>
  <blockquote>
  <p>proj_matrix = np.array([Basis_D.zerocoord, Basis_D.zerocoord])</p>
  <p>NameError: name 'Basis_D' is not defined</p>
  </blockquote>
  <p>--</p>
  <p>What I don't understand is that I can use Basis_D.dimension in the <code>init</code>, so why does it not recongise the name <code>Basis_D</code> when I use it to define <code>proj_matrix</code>?</p>