[Python-ideas] Detecting circular imports ?

Tarek Ziadé ziade.tarek at gmail.com
Thu Nov 18 17:00:43 CET 2010

On Thu, Nov 18, 2010 at 4:41 PM, Georg Brandl <g.brandl at gmx.net> wrote:
> Am 18.11.2010 16:22, schrieb Antoine Pitrou:
>> On Thu, 18 Nov 2010 16:14:35 +0100
>> Tarek Ziadé <ziade.tarek at gmail.com> wrote:
>>> 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.
>> It can't be an error, since circular imports are supported.
>> There could be a warning, but IMO it would need to be silenced by
>> default (which means ImportWarning isn't appropriate).
> I thought ImportWarning was silenced by default?
> Anyway, I don't think that would be helpful for developers, who would
> need to turn on the warnings explicitly to see them.  But to think of
> that, you already need to suspect circular imports, and then it's easy
> to see it from the traceback anyway.

mmm I am not talking about warnings here. As Ian said, and to be more
explicit the use case is:

  Your program crashed with an error because you have a circular
import -- that's a bug you need to fix.

How can we tell it in a more explicit fashion that an AttributeError
which is not very meaningful in this case ?

> Georg
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

Tarek Ziadé | http://ziade.org

More information about the Python-ideas mailing list