470,581 Members | 2,427 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,581 developers. It's quick & easy.

global statement and scoping

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):
print iter
iter = iter.next

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 ?


Mar 19 '06 #1
0 892

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

88 posts views Thread by Tim Tyler | last post: by
8 posts views Thread by David Hitillambeau | last post: by
5 posts views Thread by beliavsky | last post: by
2 posts views Thread by hrishikesh.mehendale | last post: by
2 posts views Thread by Christoph Haas | last post: by
17 posts views Thread by Chad | last post: by
27 posts views Thread by Erwin Moller | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.