ncf wrote: > In file A, I have an instance of a class and then I import file B > (import fileB as fb). In file B, I need to access file A's class > instance. Is there anyway I can do this? (I hope that was descriptive > enough :\)
Let's see... # -- fileA.py class Test(object): pass myInstance = Test() import fileB as fb fb.myInstance = myInstance fb.test() # -- fileB.py myInstance = None def test(): print "myInstance is %s" % myInstance if __name__ == "__main__": test() # -- now to the command line to test: [EMAIL PROTECTED]:~/projects/dabo/dabo/ui/uiwx $ python fileB.py myInstance is None [EMAIL PROTECTED]:~/projects/dabo/dabo/ui/uiwx $ python fileA.py myInstance is <__main__.Test object at 0xb7dfcf6c> Is this what you want? BTW, what you call "files", we refer to as "scripts" (if run) or "modules" (if imported). -- Paul McNett http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list