[Python-ideas] ImportError raised for a circular import

Oleg Broytman phd at phdru.name
Sun Jun 18 14:58:20 EDT 2017

On Sun, Jun 18, 2017 at 07:21:21PM +0100, Barry Scott <barry at barrys-emacs.org> wrote:
> I was going to simply keep track of the names of the modules that are being imported
> and raise an exception if an import attempted to import a module that had not completed
> being imported.

   Please don't do that. In SQLObject module dbconnection imports
connection modules to run registration code in their __init__;
connection modules import name DBAPI from dbconnection. To avoid
problems with circular import dbconnection imports connection modules at
the very end.
   I'm afraid you plan if implemented would prevent me from doing that.

   See the code. dbconnection.py:

   Connection modules (just a few examples):

     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.

More information about the Python-ideas mailing list