title: Subclass-safe class variable
body: <p>I can do:</p>
  
  <pre><code>class T(object):
      i = 5
  
      # then use the value somewhere in a function
      def p(self):
          print id(i), T.i
  </code></pre>
  
  <p>.. but, if I happen to subclass <code>T</code> ..</p>
  
  <pre><code>class N(T):
      pass
  </code></pre>
  
  <p>.. then <code>N.i</code> will in fact be <code>T.i</code>. I found a way to deal with this:</p>
  
  <pre><code>class T(object):
      i = 5
      def p(self):
          print self.__class__.i
  </code></pre>
  
  <p>.. is this correct and sure to work? Or can it produce unexpected behavior in some situations (which I am unaware of)?</p>