title: Call a function inside of a function inside of a class in Python
body: <p>So I'm having a problem with a larger piece of code where I'm getting an error message when I'm calling a function inside of another function that is inside of a class. In the code:</p>
  
  <pre><code>#Test program to solve problems. 
  
  class Foo(object):
      def __init__(self, number):
          self.number = number
  
      def run(self):
          print "I will now square your number"
          print "Your number squared is: "
          print self.calculate()
  
      #This squares the number
          def calculate(self):
              return self.number**2
  
  
  if __name__ == "__main__":
      test = Foo(input("Choose a number: "))
      print test.run()
  </code></pre>
  
  <p>I raise an "AttributeError: <code>Foo</code>has no attribute <code>calculate</code>", but I don't understand why? Am I calling <code>calculate</code> wrong to throw this error?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>So I know that if I change the indentation or <code>calculate</code> it works, but I wanna know is there anyway to get it working as it currently is with <code>calculate</code> indented in <code>run</code> or do python classes not work that way.</p>