Problem with modules refering to each other

Phil Hunt philh at vision25.demon.co.uk
Sun Aug 8 13:27:00 CEST 1999


In article <7ojgv8$2drq at enews1.newsguy.com>
           p.t at iname.com "Peter Torstenson" writes:
> Phil Hunt <philh at vision25.demon.co.uk> wrote in message
> news:934075710snz at vision25.demon.co.uk...
> > I have two python modules, both of which need to refer to classes
> > defined in the other one. How do I do this?
> >
> > I am currently putting at the start of each module a line of the form:
> >
> >    from theOtherModule import *
> >
> > However, this is not working. My modules -- greatly simplified -- look
> > like this:
> >
> >    #bak.py
> >    from hhh import *
> >    ti = AnHhhClass()
> >    print ti
> >
> > and:
> >
> >    #hhh.py
> >    from bak import *
> >    class AnHhhClass: pass
> >
> > When I run ``python bak.py'', I get the error message
> > ``NameError: AnHhhClass''.
> 
> Referring to something in an other module you have to put the modulename in
> front:
> Like in bak.py: "ti=hhh.AnHnnClass()"

Unfortunately this doesn't work, I get ``NameError: hhh''.

-- 
Phil Hunt....philh at vision25.demon.co.uk





More information about the Python-list mailing list