$ cat -n foo.py
1 def f():
2 str = len
3 str = str('abc')
4 # len = len('abc')
5 f()
$ python2.7 foo.py
$
它成功地運行,因此與線#2和行#3沒有問題。但經過我去掉線#4:
$ cat -n bar.py
1 def f():
2 str = len
3 str = str('abc')
4 len = len('abc')
5 f()
$ python2.7 bar.py
Traceback (most recent call last):
File "bar.py", line 5, in <module>
f()
File "bar.py", line 2, in f
str = len
UnboundLocalError: local variable 'len' referenced before assignment
$
現在報告錯誤所以必須有一些錯誤的註釋掉線#4,但爲什麼報道上線#2回溯錯誤?
只是擡頭:你最近回答的問題的作者[有問](https://meta.stackoverflow.com/questions/355936/an-answer-and-comments-just-disappear)爲什麼你刪除了你的答案,以防你想稱重。 –