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 ------------------------------------------------------------------------- Then in python shell, from test import * b=1 aa() The error message is : Traceback (most recent call last): File "<interactive input>", 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 favor. Thanks in advance
-- http://mail.python.org/mailman/listinfo/python-list