To expand/clarify C1phr's answer:
state
in the three modules will refer to the same object as long as neither a, b, nor c assigns a new value to state
. If any of the three modules does state = <something else>
, it will go out of sync. The modules can safely mutate the value (e.g., by doing state['blah'] = 'stuff'
), just not assign a new value.
As C1phr says, you can guard against this by always referring to the variable via the module containing it, as a.state
(from within b
and c
).
There are ways that one module could in theory be reloaded and thus unsync the variables, but these would be uncommon or undesirable. For instance, obviously if someone does reload(a)
then a
will be reloaded and b and c will not know about this. But this would be an unusual thing to do. Also, a module could be imported twice via different paths, which could make the variables seem to go out of sync if you didn't keep track of the two versions. But importing the same module twice in this way is pretty much always a mistake anyway.