Circular import problem

Gabriel Genellina gagsl-py2 at
Fri Jul 13 05:08:06 CEST 2007

En Thu, 12 Jul 2007 23:36:16 -0300, bvdp <bob at> escribió:

> I'm going quite nutty here with an import problem. I've got a fairly
> complicated program (about 12,000 lines in 34 modules). I just made
> some "improvements" and get the following error:
> bob$ mma
> Traceback (most recent call last):
>   File "/usr/local/bin/mma", line 55, in <module>
>     import MMA.main
>   File "/usr/local/share/mma/MMA/", line 33, in <module>
>     import
>   File "/usr/local/share/mma/MMA/", line 34, in <module>
>     import MMA.grooves
>   File "/usr/local/share/mma/MMA/", line 41, in <module>
>     import
>   File "/usr/local/share/mma/MMA/", line 35, in <module>
>     import MMA.parse
>   File "/usr/local/share/mma/MMA/", line 2052, in <module>
>     'AUTHOR': ,
> AttributeError: 'module' object has no attribute 'docs'
> I can fix this by deleting a line in Just take out the
> "import MMA.grooves" and all works. What I really don't get is that in
> the middle of this module which is now NOT loading "" I have
> a command to access a function in that module and it works.
> Yes, has an import And there are lots of other
> such imports in the program.
> So, I have to assume that the error is being generated by some other
> modules loading in the stuff ... but  really have no idea.
> Is there anything I can do to trace though this and get it working
> properly?

Try to move the circular references later in the code (maybe inside a  
function, when it is required), or much better, refactor it so there is no  

Gabriel Genellina

More information about the Python-list mailing list