I have read the documentation and also this comprehensive answer but something doesn't work as I expect. I hoped to use from set_stuff_up import *
as basically an "include" statement to define some boilerplate globals and functions, but something doesn't work as I'd expect. Here is set_stuff_up.py:
public_name = None
def set_public_name():
global public_name # makes no diff
public_name = 'HELLO DERE'
However the following code:
from set_stuff_up import *
print('public_name is',public_name)
set_public_name()
print('public_name is',public_name)
produces the output:
public_name is None
public_name is None
In other words, from set_stuff_up import *
did bind public_name
"in the local namespace for the scope where the import statement occurs" but somehow the function set_public_name
operates on a different public_name, regardless of the global statement.
Can somebody clarify the way the namespaces are operating in this case? And is there a way to have the imported function operate on the imported public name?