title: NameError: name is not defined in python init function
body: <pre><code>class HumidityServer(CoAP):
      def __init__(self, host, port, noOfSensors=10, multicast=False):
          CoAP.__init__(self, (host, port), multicast)
  
          for num in range(noOfSensors):
              self.add_resource('humidity'+num+'/', HumidityResource(num))
  </code></pre>
  
  <p>This excerpt is part of a program that generates:</p>
  
  <pre><code>Traceback (most recent call last):
    File "humidityserver.py", line 10, in &lt;module&gt;
      class HumidityServer(CoAP):
    File "humidityserver.py", line 14, in HumidityServer
      for num in range(noOfSensors):
  NameError: name 'noOfSensors' is not defined
  </code></pre>
  
  <p>Why does this happen even though I've defined a default value for the variable?</p>