ActiveState Python won't call module function.

Mel Wilson mwilson at
Sat Nov 29 22:11:42 CET 2003

In article <bqatc6$1pv$1 at>,
"Glenn Reed" <dont_use at> wrote:
>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):
>        self.x=23
>        self.y=14
>        self.z=33
>        self.x1=self.x=3
># 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):
>  File
>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

   And it isn't.  'module1.module2' is defined in your main
module, though.

    thisClass = module1.module2()

should work fine.  (Hint: module1 doesn't have to import itself
to get the symbols it defines.)

        Regards.        Mel.

More information about the Python-list mailing list