In C/C++, if we have the following header a.h
#include "b.h"
#include "c.h"
#include "d.h"
Then, if we include a.h, b.h, c.h, and d.h are also automatically included. So, it is easy to include multiple related headers simultaneously.
However, in Python it seems that the story is different. Suppose that we have a Python module named a.py as shown:
import b
import c
import d
In this case, even if I import a, b, c, and d are not automatically imported.
In short, I want to find a way to import a group of modules easily. Are there any ways for me to do this?
You can use an alternate method:
from a import *
When you use #include in C/C++, it is not part of the compiler. It is part of the preprocessor. If my main.cpp has an include, the preprocessor copy all code of the included file. In Python, it is differently because, the preprocessor does not exist, and the interpreter imports the specific module only for the file that has imported.
If you want to import several modules, you must use from a import *.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With