I
icarus
global_vars.py has the global variables
set_var.py changes one of the values on the global variables (don't
close it or terminate)
get_var.py retrieves the recently value changed (triggered right after
set_var.py above)
Problem: get_var.py retrieves the old value, the built-in one but not
the recently changed value in set_var.py.
What am I doing wrong?
----global_vars.py---
#!/usr/bin/python
class Variables :
def __init__(self) :
self.var_dict = {"username": "original username"}
---set_var.py ---
#!/usr/bin/python
import time
import global_vars
global_vars.Variables().var_dict["username"] = "new username"
time.sleep(10) #give enough time to trigger get_var.py
---get_var.py ---
#!/usr/bin/python
import global_vars
print global_vars.Variables().var_dict.get("username")
set_var.py changes one of the values on the global variables (don't
close it or terminate)
get_var.py retrieves the recently value changed (triggered right after
set_var.py above)
Problem: get_var.py retrieves the old value, the built-in one but not
the recently changed value in set_var.py.
What am I doing wrong?
----global_vars.py---
#!/usr/bin/python
class Variables :
def __init__(self) :
self.var_dict = {"username": "original username"}
---set_var.py ---
#!/usr/bin/python
import time
import global_vars
global_vars.Variables().var_dict["username"] = "new username"
time.sleep(10) #give enough time to trigger get_var.py
---get_var.py ---
#!/usr/bin/python
import global_vars
print global_vars.Variables().var_dict.get("username")