Understanding includes

what if an include file itselfs include a file that is included in the main file. i.e.

file_a.py
from file_b include *
from file_c include *
file_b.py
from file_c include * 

include * is ok as the include files are from me

I C++ I have a mechanism to prevent multiple includes, how does tah work in Python or does Python do this itself.

Background: I have on python file where all my constants of the project are defined and another where some global used functions are defined
I want both used in some other scripts.
Any hint
Thank you

It is not an include in python it is an import.
Each time a module is imported it is recorded in sys.modules.

If you import a module twice the second time python notices that the module is already imported and uses the existing module.

2 Likes

Ok I understand, thank you