Answers for "python global variable across files"

24

python global variables

global var1
var1 = 'whatever'
Posted by: Guest on February-24-2020
1

python global variable across files

# config.py
x = 0

# mod.py
import config
config.x = 1

# main.py
import config
import mod
print(config.x) # will print '1'
Posted by: Guest on November-06-2020

Python Answers by Framework

Browse Popular Code Answers by Language