Python: Why are circular imports bad?

Asked 2 years ago

I've heard that circular imports are generally considered bad in Python. Can someone explain why this is the case?

Roberto Ray

Wednesday, July 06, 2022

Circular imports are bad because they can lead to unexpected behavior and errors. When two modules are imported, the interpreter will execute the code in both modules. If the modules have variables or functions with the same name, the value of the variable or function in the second module will overwrite the value in the first module. This can lead to unexpected results.

Write an answer...


Please follow our  Community Guidelines

Can't find what you're looking for?