Thursday, 22 August 2013

Import global variable with latest assigned value

Import global variable with latest assigned value

I'm trying to import global variable from one file to another. Though the
value of variable is changed at multiple location and i need to import
latest value that global variable carries.
file_One.py:
a = "Old Value"
def some_somefunction():
global a
a = "New Value"
Now I need the global variable with value "New Value" to be imported.
file_two.py:
import file_One
print file_One.a
o/p
Old value
Is there a way i can import global variable a with "New Value"?

No comments:

Post a Comment