Hi,
Can anyone explain the following:
Python 2.5 (r25:51908, Apr 9 2007, 11:27:23)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
.... x = 2
....
.... x[2] = 2
....
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in bar
NameError: global name 'x' is not defined
Thanks,
Jianbing
Can anyone explain the following:
Python 2.5 (r25:51908, Apr 9 2007, 11:27:23)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>def foo():
....
>>foo()
>>def bar():
>>def bar():
....
>>>
>>bar()
>>bar()
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in bar
NameError: global name 'x' is not defined
Thanks,
Jianbing
Comment