title: Not able to access object in python while creating object of other class defined in some other file
body: <p>I have a directory structure like this:</p>
  
  <pre><code>home/
      main.py
  
      lib/
         mylib/
              Textfile_Class.py
              Excelfile_Class.py
              globals.py   (has all the global variables declared here)
              functions.py
  </code></pre>
  
  <p>I created an object of <code>Textfile_class</code> in <code>main.py</code> using 
  <code>txt = TEXT(file)</code>.</p>
  
  <p>Now, I want to use this variable <code>txt</code>  during creating object of <code>Excelfile_Class</code> for some operations (eg, if the value of a variable in <code>txt</code> object is 5, then do certain action in <code>Excelfile_Class )</code></p>
  
  <p>In <code>Excelfile_Class</code>, I am also importing all the global variables. String variables are accessible there but I dont know why this object <code>txt</code> is not accessible there. Wherever I am refering to <code>txt</code> in <code>Excelfile_Class</code>(<code>self.line_count = txt.count</code>), I am getting below error: <code>AttributeError: 'NoneType' object has no attribute 'count'</code></p>
  
  <p>Please help me to know why this is happening even though I have defined all the variables in a seperate file and importing those in all the files.</p>
  
  <p>Eg:
  main.py</p>
  
  <pre><code>path = os.path.abspath('./lib')
  sys.path.insert(0, path)
  
  from mylib.Textfile_class import * 
  from mylib.Excelfile_Class import *
  from mylib.globals import *
  from mylib.functions import *
  
  if __name__ == "__main__":   
      txt = TEXT(file)
      xcel = EXCEL(file)
  </code></pre>
  
  <p>Eg globals.py</p>
  
  <pre><code>global txt, xcel
  txt=None
  xcel=None
  </code></pre>
  
  <p>Eg Textfile_class.py</p>
  
  <pre><code>from globals import *
  class TEXT:
      def __init__(self, filename):
          self.count = 0
          with open(filename) as fp:
              for line in fp:
                  self.count = self.count + 1`
  </code></pre>
  
  <p>Eg Excelfile_Class.py</p>
  
  <pre><code>from globals import *
  
  class EXCEL:
      def __init__(self, filename):
          self.line_count = 0
          self.operation(filename)
  
      def operation(self, file):
          self.line_count = txt.count 
          if self.line_count:
              self.some_operation()
          else:
              self.other_operation()
  </code></pre>