global statement and scoping
jochen.stier at gmail.com
jochen.stier at gmail.com
Sun Mar 19 16:34:28 EST 2006
Hi everyone,
I am compiling the following script using Py_CompileString
def compute(node):
#global compute
iter = node.getChild(0)
while iter:
if isinstance(iter, Group):
compute(iter)
print iter
iter = iter.next
compute(self.a0)
The I evaluate the script using PyEval_EvalCode and get a ''global name
"compute" is not
defined' error at the line of the recursive call. When I comment in the
"global" statement at the beginning of the function then everything
works fine. What's strange is the once I comment out the statement
again it still works... Somewhere something is written into a
dictionary in dunno where ?
Is it normal to have the global statement at the beginning of a
function like that ?
Cheers
Jochen
More information about the Python-list
mailing list