Apr-03-2019, 07:58 AM
(This post was last modified: Apr-03-2019, 07:58 AM by Gribouillis.)
It is because each module has its own global namespace, so the global
a
in module code
is not the global a
in module __main__
. You can usefrom code import * import code func() print(code.a)It is usually best to avoid functions that update global variables.