ActiveState Python won't call module function.
Glenn Reed
dont_use at nowhere.com
Sat Nov 29 14:56:22 EST 2003
Hi,
This is probably a really easy question and I apologize if it is already
covered in some faq somewhere.
These are my two source files:
------- module1.py -------------
class module2:
def __init__(self):
self.x=23
self.y=14
self.z=33
self.x1=self.x=3
#thisClass=module2()
# I added the above line in just to test it works here and it does.
------- tmod.py ---------------
# Test Module
import module1
thisClass = module2()
----------------------------------------------
It generates the following error:
Traceback (most recent call last):
File
"C:\Python22\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 301, in RunScript
exec codeObject in __main__.__dict__
File "C:\My Documents\PythonSrc\Temp\tmod.py", line 4, in ?
thisClass = module1()
NameError: name 'module2' is not defined
>>>
I realize I have created a different class name 'module2' to the filename
'module1' but I was thinking at the time the error may be due to a namespace
clash between the name of the file and the name of the class or the filename
hiding the classname etc.
But this has got me stumped and I would appreciate any help on it.
Thanks in advance.
Glenn.
More information about the Python-list
mailing list