On Tue, 28 Dec 2004 19:59:01 GMT, It's me <[EMAIL PROTECTED]> wrote: > > "Premshree Pillai" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Tue, 28 Dec 2004 19:34:36 GMT, It's me <[EMAIL PROTECTED]> wrote: > > > This must be another newbie gotchas. > > > > > > Consider the following silly code, let say I have the following in > file1.py: > > > > > > #============= > > > import file2 > > > global myBaseClass > > > myBaseClass = file2.BaseClass() > > > myBaseClass.AddChild(file2.NextClass()) > > > #============= > > > > You have declared myBaseClass to be global, but it doesn't exist. > > > > No, myBaseClass exists in file1.py. The question is how can I tell
Umm, from the sample code (for file2.py) that you provided, I don't see myBaseClass. You've only declared it to be global in file2.py, but it does not exist -- does not exist in the sense that it has no type associated with it, which in turn means meaning you cannot apply methods to it. > file2.py that the global variable is in file1 (without doing a silly > file1.myBaseClass.... > > Since I am invoking file2 from file1, I would have thought that global > variables in file1 exists automatically....(too much C thinking, I know) > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Premshree Pillai http://www.livejournal.com/~premshree -- http://mail.python.org/mailman/listinfo/python-list