'Problem transferring variables between modules
# Config.py
mess = ''
print('*',mess,'*')
#------------------------
# try1.py
while True:
import Config
mess = input('Input: ')
Config.mess = mess
import try2
if mess == '':
break
#------------------------
# try2.py
import Config
print('=', Config.mess, '=')
#---The result ----------
* *
Input: 111
= 111 =
Input: 222
Input: 333
#------------------------
Try1.py takes an entered variable (mess) and passes it to try2.py to print. Using Config.py.
It works the first time only.
Also tried to unload (del) Try2.py after each input, but gave me the same result.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
