[Tutor] seeking design pattern
bob gailer
bgailer at gmail.com
Sat Aug 24 20:39:55 EDT 2019
I desire to import some functions form a module and give them access to
names in the main module namespace. Example:
m.py ---------------
def a():
print(s)
interactive interpreter ---------------
>>> s = 3
>>> from m import a
>>> a()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "N:\m.py", line 2, in a
print(s)
NameError: name 's' is not defined
My expectation was that the function, having been imported into the main
module, would access variables in the main module, but alas, not the case.
Is there a workaround? ( easy, "clean", pythonic)
--
Bob Gailer
More information about the Tutor
mailing list