Python 3.x.x one variable spread across multiple .py files -
This is not a problem with my code, but there is a general question about dragon 3.
Say you had a game with 4 parts, and the first part ( main.py
) declares a variable that says Part 2 needs to run itself Will you be able to declare that variable, then import part2
(it needs a variable to run smoothly) and the variable in the main.py
Code> part2 to main.py
in part2.py
after importing .py .
If you want to use the variable after doing this once.
If you want to be able to make variable changes later
or just do this:
# part2.py # Gvars def defream (): print (gvars.sound) # part1.py imports part2 class gamereality: if pass __name__ == "__ main__": gvars = gameVariables () part2.gvars = gvars gvars.sound = "Yooo" part2 .scream () gvars.sound = "wow" part2.scream () #output Yooo Wha
Comments
Post a Comment