title: python Exception AttributeError: "'NoneType' object has no attribute 'var'"
body: <p>im getting this exception in Python,</p>
  
  <pre><code>Exception AttributeError: "'NoneType' object has no attribute 'population'" in del of &lt;main.Robot instance at 0x104eb7098&gt;&gt; ignored
  </code></pre>
  
  <p>this is my code,</p>
  
  <pre><code>class Robot:
  
      population = 0 #class variable, number of robots
  
      def __init__(self, name):
  
          self.name = name
          print ('(initializing {0})'.format(self.name))
  
          Robot.population += 1
  
      def __del__(self):
          print('{0} is being destroyed!'.format(self.name))
          Robot.population -= 1
  
          if Robot.population == 0:
              print ('{0} was the last one.'.format(self.name))
          else:
              print('there are still {0:d} robots working.'.format(Robot.population))
  
      def sayHi(self):
          print('hole mi mestre me llama {0}'.format(self.name))
  
      def howMany():
          print('hay {0:d} robots'.format(Robot.population))
      howMany = staticmethod (howMany)
  
  
  #instantiate 2 robots
  mingos = Robot('alvergas')
  mingos.sayHi()
  Robot.howMany()
  
  pingos = Robot('chupacabra')
  pingos.sayHi()
  Robot.howMany()
  
  #destroy one
  del mingos
  
  Robot.howMany()
  </code></pre>
  
  <p>Thanks!</p>