Re: problem with global variable in a module

2006-11-25 Thread hollowspook
Thanks for all the replys. "Diez B. Roggisch 写道: " > hollowspook schrieb: > > def aa(): > > global b > > b=b+1 > > print b > > > > b=1 > > aa() > > > > The above code runs well in python shell. > > > > However I have a problem as follows. > > > > new a file named test.py > >

Re: problem with global variable in a module

2006-11-25 Thread Diez B. Roggisch
hollowspook schrieb: > def aa(): > global b > b=b+1 > print b > > b=1 > aa() > > The above code runs well in python shell. > > However I have a problem as follows. > > new a file named test.py > > > def aa():

Re: problem with global variable in a module

2006-11-25 Thread Duncan Booth
"hollowspook" <[EMAIL PROTECTED]> wrote: > from test import * > b=1 > aa() > > The error message is : > Traceback (most recent call last): > File "", line 1, in ? > File "test.py", line 3, in aa > b=b+1 > NameError: global name 'b' is not defined > > Why this happens? Please do me a favo

problem with global variable in a module

2006-11-25 Thread hollowspook
def aa(): global b b=b+1 print b b=1 aa() The above code runs well in python shell. However I have a problem as follows. new a file named test.py def aa(): global b b=b+1 print b -