ActiveState Python won't call module function.

Glenn Reed dont_use at
Sat Nov 29 20:56:22 CET 2003


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:
------- -------------
class module2:
    def __init__(self):

# I added the above line in just to test it works here and it does.
------- ---------------
# Test Module
import module1

thisClass = module2()


It generates the following error:
Traceback (most recent call last):
line 301, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\My Documents\PythonSrc\Temp\", 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.

More information about the Python-list mailing list