I have below script files:
1. master.py
2. setup.py
4. core1.py
5. core2.py
master.py:
import setup.py
import standard.py
import core1.py
import core2.py
if __name__ = '__main__':
#how to access var1, var2, var3..var100 of setup1?
do something
setup.py:
def somefunction():
var1 = x
var2 = y
var3 = z
#.... so on var100 = z100
core1.py:
import setup
#how to access var1, var2, var3..var100 of setup1?
#written few functions which require setup.py variables output
core2.py:
import setup
#how to acess var1, var2, var3..var100 of setup1?
#written few functions which require setup.py variables output
Program execution flow:
-->run master.py--> import setup, core1, core2, --> call core1 functions inside master.py ---> call core2 functions inside master.py
how to access var1, var2, var3..var100 of setup1 script variables in all the script?
Please correct me if anything mistakes i am doing in execution flow design.
You need to make your var1 ... var100
variables global
, so that they can be accessed outside of the function they're in.
To access them in each file, you need to first call the function in setup.py
(like setup.someFunction()
), and then you can use them as you would use variables normally.
EDIT: In answer to your comment, yes, you want to call it in all of the files.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.