I have two files:
script1.py :
myValue = 0
def addition(a_value):
a_value += 1
return a_value
if __name__ == '__main__':
myValue = addition(myValue)
myValue = addition(myValue)
print(myValue)
script2.py :
from script1 import *
def getMyValue():
my_new_value = addition(myValue)
print(my_new_value)
getMyValue()
When script1
is executed it returns 2
, and this is what I want.
But when script2
is executed, it returns 1
. How can I get the preserved result 2
from script2
?
If I want to execute addition()
multiple times and always get the updated result in script2
instead of getting 1
every time?
Thank you for your replies.