On Feb 25, 10:25 pm, [EMAIL PROTECTED] wrote: > Hello everybody, > > I have a (hopefully) simple question about scoping in python. I have a > program written as a package, with two files of interest. The two > files are /p.py and /lib/q.py > > My file p.py looks like this: > > --- > > from lib import q > > def main(): > global r > r = q.object1() > s = q.object2() > > if __name__ == "__main__": > main() > > --- > > My file q.py in the subdirectory lib looks like this: > > class object1: > t = 3 > > class object2: > print r.t
"Globals" are only global within the module they are defined in. Change "global r" to "import __main__; __main__.r = r", and in q.py add "from __main__ import r". -- http://mail.python.org/mailman/listinfo/python-list