[Python-ideas] Detecting circular imports ?

Nick Coghlan ncoghlan at gmail.com
Fri Nov 19 14:15:31 CET 2010

On Fri, Nov 19, 2010 at 1:14 AM, Tarek Ziadé <ziade.tarek at gmail.com> wrote:
> Hello,
> This morning I tried to fix an issue for a while before I realized I
> had a circular import. This issue is not obvious because you get a
> cryptic error, like an AttributeError and it can tak a while before
> finding out.
> I don't know of this was mentioned before, or how hard it would be.
> But it would be nice if Python had a specific "CircularImportError"
> raised in that case, or something..
> That would be a fabulous hint for developers.

Feel free to take a shot at it - the relevant bug report [1] is only a
little over 6 years old! :)

If we could detect the situation well enough to give a specific error
message for it, we could probably do something smarter about it than

I find my naive early messages about the import subsystem from back
then are kind of amusing now, though... little did I know what evils
lurked beneath the surface of the import statement...


[1] http://bugs.python.org/issue992389

Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list