Hi.
I have a hundred lines of code in a module that declare some global
variables inside a function so that those variables can be used by
other functions. I want to import this module so that I can more
easily debug by looking at the value of individual variables. But
when I try to reach these variables, I get a warning that they are not
defined.
I am on an Intel Mac running Leopard 10.5.2, Python 2.5
Here is an example of some code that has the same problem:
#!/usr/bin/env python
global isglobal
isglobal=200
def somefunc():
global from_somefunc
from_somefunc=5
def anotherfunc():
return from_somefunc+30
So during debugging I want to look at the variable from_somefunc
here is my terminal output. I start by looking at dir(), then run
somefunc(), then run anotherfunc(), then I want to look at
from_somefunc but I get a warning:
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from test_vars import *
>>> dir()
['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal',
'somefunc']
>>> somefunc()
>>> anotherfunc()
35
>>> isglobal
200
>>> from_somefunc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'from_somefunc' is not defined
>>> dir()
['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal',
'somefunc']
Is there a way that I can view from_somefunc?
Thanks,
Jake
--
http://mail.python.org/mailman/listinfo/python-list