title: Local Variable referenced before assignment inside of a class
body: <p>Here's the situation</p>
  
  <pre><code>class Person(object):
      NumRid = 1
      def __init__(self, name, rid = NumRid):
          self.name = name
          self.rid = rid
          NumRid += 1
  
  class Investor(Person):
      pass
  </code></pre>
  
  <p>then I enter the interactive python session, and type in <code>from file import *</code>
  and then
      Investor('Bob')
  and it tells me that local variable NumRid is referenced before assignment, at <code>NumRid += 1</code>.</p>
  
  <p>as far as I can tell from googling, NumRid should be in the local namespace of the class and accessible from the class function.... so what's up with this? do I need to declare both to be global; or is there a magic word I can type to make it look up NumRid in the class namespace if there is one?</p>