In config.py, I have:
config = 0
#config = []
def init_config():
global config
config = 1
#config.append("1")
print("init", config)
In main.py, I have:
from config import init_config
from config import config
def main():
init_config()
print("main", config)
if __name__ == '__main__':
main()
And both the config.py and the main.py in the same directory. After running python main.py
, I got:
init 1
main 0
But if I use the comment lines in the config.py instead, I got:
init ['1']
main ['1']
So why does the difference happen? (Python 3.5.5)