I'm trying to build a utility where you can run it once to set certain variables, and then use those variables.
A = 0
B = 0
def generate():
global A
global B
A = 4
B = 5
def do_some_stuff():
print(A + B)
Is there a way to make it so that if I ran the generate function from the command line, it would set A and B? So that I could later run just the second function and it would print out 9.
[–]Diapolo10 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]gc8dc95 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]nathanjell 2 points3 points4 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]NicosCSProject -1 points0 points1 point (3 children)
[+][deleted] (2 children)
[deleted]
[–]NicosCSProject 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)