Mel <[EMAIL PROTECTED]> wrote: > oyster wrote: >> why the following 2 prg give different results? a.py is ok, but b.py >> is 'undefiend a' >> I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC >> v.1310 32 bit (Intel)] on win32 >> #a.py >> def run(): >> if 1==2: # note, it always False >> global a >> a=1 >> >> run() >> a >> >> #b.py >> def run(): >> a=1 >> >> run() >> a > > The docs seem to be in <http://www.python.org/doc/2.4/ref/global.html> > but don't look all that helpful.
Why are you reading Python 2.4 docs? Try http://docs.python.org/ref/global.html The first sentence (which hasn't changed since 2.4) describing the global statement seems clear enough to me: "The global statement is a declaration which holds for the entire current code block." -- http://mail.python.org/mailman/listinfo/python-list