title: Can a function access the instance of a class without using global in python?
body: <p>Why can I use the instance of a class in the following function without using globals?</p>
  
  <pre><code>class TestClass:
      def __init__(self, name):
          self.name = name
      def MyName(self):
          print "My name is: " + self.name
  
  def testFunc():
      # why can I use the instance here?
      print "in testFunc()"
      instance.MyName()
  
  if __name__ == '__main__':
      instance = TestClass("abc")
      print "in __main__"
      instance.MyName()
  
      testFunc()
  </code></pre>