title: Python 3 Accessing variable result from another Class
body: <p>I have a little problem with a variable update.</p>
  
  <p>I have my variable declared in my first function as such  self.TestVar = 0
  then if a certain count ==2 self.TestVar = 2</p>
  
  <p>in a second function (in the same class) but called from within another class I want returning self.TestVar. no way.</p>
  
  <pre><code>AttributeError: 'ThndClass' object has no attribute 'TestVar'
  </code></pre>
  
  <p>I am most certainly not doing the good way, all I want is accessing self.TestVar = 2 from my other class that's it's but I can't find a proper way to do so in Python. 
  It looks like my issue is that I get my self.TestVar = 2 in a "if" statement which make it live in another scope (or I might be wrong).</p>
  
  <pre><code>import sys
  from PIL import Image
  from PyQt4 import QtCore, QtGui
  
  
  class MainWindow(QtGui.QWidget):
  
      def __init__(self):
          super(MainWindow, self).__init__()
          self.initUI()
  
      def initUI(self):
  
          self.TestVar = 0
          self.TheCount = 2
          if self.TheCount ==2:
              self.TestVar = 2
          ThndClass()
  
  
  
  
      def Getit(self):
          print("called correctly")
          print(self.TestVar)
          return  self.TestVar
  
  
  
  def main():
  
      app = QtGui.QApplication([])
      mw = MainWindow()
      sys.exit(app.exec_())
  
  
  class ThndClass(QtGui.QWidget):
      def __init__(self):
          super(ThndClass, self).__init__()
          self.initUI2()
  
      def initUI2(self):
          print("Class Called")
          print(MainWindow.Getit(self))
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>If I remove the 2nd Class call :</p>
  
  <pre><code>import sys
  from PIL import Image
  from PyQt4 import QtCore, QtGui
  
  
  
  
  class MainWindow(QtGui.QWidget):
  
      def __init__(self):
          super(MainWindow, self).__init__()
          self.initUI()
  
      def initUI(self):
  
          self.TestVar = 0
          self.TheCount = 2
          if self.TheCount ==2:
              self.TestVar = 2
          self.Getit()
  
  
  
  
      def Getit(self):
          print("called correctly")
          print(self.TestVar)
          return  self.TestVar
  
  
  
  def main():
  
      app = QtGui.QApplication([])
      mw = MainWindow()
      sys.exit(app.exec_())
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>This works correctly, but I want to be able to call  def Getit() from another class and get my result. Or simply get a way to directly access self.TestVar from my other class.</p>