RE: A scoping question

2004-12-29 Thread Gabriel Cosentino de Barros
Title: RE: A scoping question > myBaseClass.AddChild(file2.NextClass()) > [snip] > class NextClass: > def __init__(self): > for eachChild in myBaseClass.MyChilds:  # <- ERROR > ... I never assumes globals in my classes. always pass them as param

naming conventions (WAS: A scoping question)

2004-12-28 Thread Steven Bethard
It's me wrote: #= import file2 global myBaseClass myBaseClass = file2.BaseClass() myBaseClass.AddChild(file2.NextClass()) #= [snip] #= global myBaseClass class BaseClass: def __init__(self): self.MyChilds = [] ... def AddChild(NewChild):

Re: A scoping question

2004-12-28 Thread It's me
Thanks, Steve. So, global is only to within a module (I was afraid of that). Those words flashed by me when I was reading it but since the word "module" didn't translate to "file" in my C mind, I didn't catch that. In that case, you are correct that I have to do an import of file1 in file2. Not

Re: A scoping question

2004-12-28 Thread Steven Bethard
It's me wrote: This must be another newbie gotchas. Consider the following silly code [snip tightly coupled code] A few options that also might work better than such tightly coupled modules: file1.py import file2 myBaseClass = file2.BaseClass() class NextCl

Re: A scoping question

2004-12-28 Thread Steven Bethard
It's me 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()) #= and in file2.py, I have: #==

Re: A scoping question

2004-12-28 Thread Premshree Pillai
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 fol

Re: A scoping question

2004-12-28 Thread It's me
"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: > > > > #=

Re: A scoping question

2004-12-28 Thread Premshree Pillai
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.AddCh

A scoping question

2004-12-28 Thread It's me
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()) #= and in file2.py, I have: #= global