Hello,
I am trying to use global variables to control the behaviour of Python
functions called from Sage. (Yes, I know there is probably a better way to
do it, but I am still interested in what's going on here.)

##
Advertising

If in foo.py I have
def bar():
print blah
def baz():
global zilch
zilch = 0
and, in Sage I do:
sage: from foo import bar
sage: global blah
sage: blah = 1
sage: bar()
the result is:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-4c8101bd3664> in <module>()
----> 1 bar()
/home/leopardi/sync/src/sage-sandbox/Boolean-Cayley-graphs/foo.py in bar()
1 def bar():
----> 2 print blah
NameError: global name 'blah' is not defined
If instead I do:
sage: from foo import baz
sage: baz()
sage: print zilch
the result is:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-af9f97ada0b7> in <module>()
----> 1 print zilch
NameError: name 'zilch' is not defined
Is there a way in Sage that I can assign to a global variable that a called
Python function will recognize as a global variable?
Thanks, Paul
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.