title: Using constants in constructor
body: <p>I am getting an error when I try to use a constant inside a constructor in a class.  I have searched for a resolution to the issue all morning and I can make the program function by using if/else statements in the getter but the instructions are to use the constants.</p>
  
  <pre><code>class Fan:
  
      SLOW = 1
      MEDIUM = 2
      FAST = 3
  
      def __init__(self, speed=SLOW, radius=5, color='blue', on=False):
          self.__speed = speed
          self.__on = on
          self.__radius = radius
          self.__color = color
  
      def getSpeed(self):
          return self.__speed
  
      def getRadius(self):
          return self.__radius
  
      def getColor(self):
          return self.__color
  
      def getOn(self):
          return self.__on
  
      def setSpeed(self, speed):
          self.__speed = speed
  
      def setRadius(self, radius):
          self.__radius = radius
  
      def setColor(self, color):
          self.__color = color
  
      def setOn(self, on):
          self.__on = on
  
  fan1 = Fan(FAST, 10, 'yellow', True)
  fan2 = Fan(MEDIUM, 5, 'blue', False)
  
  print(fan1.getSpeed())
  print(fan1.getRadius())
  print(fan1.getColor())
  print(fan1.getOn())
  print()
  print(fan2.getSpeed())
  print(fan2.getRadius())
  print(fan2.getColor())
  print(fan2.getOn())
  </code></pre>
  
  <p>When I run this code I get the following error "NameError: name 'FAST' is not defined"</p>
  
  <p>Any help and explanation would be appreciated.</p>