Scope - import and globals

Troels Thomsen nejtak...
Tue May 29 12:34:42 EDT 2007


"HMS Surprise" <john at datavoiceint.com> skrev i en meddelelse 
news:1180455769.891470.116360 at p47g2000hsd.googlegroups.com...
>
> In the file snippet below the value for the global hostName is
> determined at runtime. Functions imported from the parent  baseClass
> file such as logon also need access to this variable but cannot see it
> the with the implementation I have attempted here.
>
> Also, functions in this file and in the imported parent class need
> PyHttpTestCase. Does there need to be an import statement in both
> files?
>

If a file needs an import, make the import!
Dont rely on other file's imports , in general, imho.

Not sure excactly what you are doing, but are you sure you dont want an 
instance variable instead of a global ?
self.hostName = "blah"
And then a getHostName() method in the class ?

regards
Troels






More information about the Python-list mailing list