AI engineering glossary · Python advanced

What is circular import?

Circular import: A situation where two modules import each other, directly or through a chain, so one is used before it has finished loading. It usually raises an ImportError and is fixed by restructuring or delayed imports.

Level: advancedTopic: Python advanced

Circular import: an example

a.py imports b.py, which imports a.py again, and accessing a name from a partly loaded module fails.

Related terms

More Python advanced terms

Where you learn it

Circular import is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.