title: Calling functions from main python
body: <p>I have some python 3.4 code that works fine:</p>
  
  <pre><code>def run():
      m = 0
      while m != 1:    
          p = input('Please choose p: ')
          p = makeInt(p)
          #Some other code
          print(p)
          m = makeInt(input('Enter 1 if you would like to quit: '))
  
  def makeInt(i):
      try:
          i = int(i)
      except ValueError:
          i = input('Incorrect input! Enter your answer: ')
          i = makeInt(i)
      return i
  
  #Some other functions    
  
  if __name__ == '__main__':
      run()
  </code></pre>
  
  <p>I want to put all this code in a class (Except possibly <code>if __name__ ==</code>...) When I put all the code including <code>if __name__ ==</code>... in a class like so:</p>
  
  <pre><code>class Foo(object):
      def run(self):
          m = 0
          while m != 1:    
              p1 = input('Please choose p: ')
              p1 = self.makeInt(p1)
              #Some other code
              print(p1)
              m = self.makeInt(input('Enter 1 if you would like to quit: '))
  
      def makeInt(self, i):
          try:
              i = int(i)
          except ValueError:
              i = input('Incorrect input! Enter your answer: ')
              i = self.makeInt(i)
          return i
      #Some other functions and stuff
  
      if __name__ == '__main__':
          run()
  </code></pre>
  
  <p>I get the following error: <code>TypeError: run() missing 1 required positional argument: 'self'</code>.  When I remove the self argument from <code>run()</code> it runs until <code>makeInt()</code> is called and then I get: <code>NameError: name 'makeInt' is not defined</code>.  I get the same error if I take the if statement out of the class and call <code>Foo.run()</code>.  I have some other code earlier in this program that works when I call functions of a class from another function in that same class.  I realize I don't have to put all my code in a class, but in this case I want to. Why am I getting these errors and what can I do to put my working code in a class? </p>