-
Notifications
You must be signed in to change notification settings - Fork 19
Description
This is a problem that has been hindering my use of Pyonic interpreter for several years. I'm kind of surprised that it is not listed as a known issue or hasn't been reported yet.
Basically, in both Pyonic 2 & 3, functions that I define and variables that I assign at the top-level of the interpreter are not visible as globals within other functions (or even themselves -- no recursion). A simple example:
def foo():
print("foo")
def bar():
foo()
print("bar")
bar()
The call to foo()
from bar()
raises NameError
with the message "global name 'foo' is not defined" in Python 2.7 and "name 'foo' is not defined" in Python 3.6.
dir()
shows both foo and bar but globals()
does not. I've been working around the problem by passing in functions as default parameters to functions but this has some limitations. (For one thing, recursion doesn't work properly).
I was hoping to try fixing this myself but I have no experience with Kivy or Python for Android and unfortunately don't have time to try to set up those tools.
Thanks!
Anthony Kozar