A scoping question

It's me itsme at yahoo.com
Tue Dec 28 14:59:01 EST 2004


"Premshree Pillai" <premshree.pillai at gmail.com> wrote in message
news:mailman.8524.1104263434.5135.python-list at python.org...
> On Tue, 28 Dec 2004 19:34:36 GMT, It's me <itsme at yahoo.com> 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
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)





More information about the Python-list mailing list