在 Python (2.7.2) 中,为什么
import dis
dis.dis("i in (2, 3)")
按预期工作而
import dis
dis.dis("i in [2, 3]")
提出:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dis.py", line 45, in dis
disassemble_string(x)
File "/usr/lib/python2.7/dis.py", line 112, in disassemble_string
labels = findlabels(code)
File "/usr/lib/python2.7/dis.py", line 166, in findlabels
oparg = ord(code[i]) + ord(code[i+1])*256
IndexError: string index out of range
请注意,这不会影响 Python3。