While it is valid to use from module import * at module level it is
usually a bad idea. For one, this loses an important property Python
otherwise has — you can know where each toplevel name is defined by a
simple “search” function in your favourite editor. You also open
yourself to trouble in the future, if some module grows additional
functions or classes.
Actually this is not really the same to import a variable with:
from file1 import x1
print(x1)
and
import file1
print(file1.x1)
Altough at import time x1 and file1.x1 have the same value, they are not the same variables. For instance, call a function in file1 that modifies x1 and then try to print the variable from the main file: you will not see the modified value.
Marc response is correct. Actually, you can print the memory address for the variables print(hex(id(libvar)) and you can see the addresses are different.
In Python you can access the contents of other files like as if they
are some kind of a library, compared to other languages like java or any
oop base languages , This is really cool ;
This makes accessing the contents of the file or import it to to process
it or to do anything with it ;
And that is the Main reason why Python is highly preferred Language for
Data Science and Machine Learning etc. ;
And this is the picture of project structure
Where I am accessing variables from .env file where the API links and
Secret keys reside .