Scope - import and globals

HMS Surprise john at datavoiceint.com
Tue May 29 12:22:49 EDT 2007


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?


Thanks,

jh

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


from PyHttpTestCase import PyHttpTestCase
from baseClass import baseClass

# definition of test class
class temp(baseClass):

    def runTest(self):
	global hostName
	hostName = getHostNameFromUser()
	self.logon()




More information about the Python-list mailing list