为什么在if/else中执行pass语句?

min*_*iao 1 python if-statement

当我在调试模式下运行以下if/else时

if True:
  print 'here'
else:
  print 'there'
  pass  # breakpoint here
Run Code Online (Sandbox Code Playgroud)

调试器在pass语句上停止.为什么pass语句被执行?我知道这pass是无关紧要的,但它在里面else.

我在Pycharm 2.7.3上运行python 2.7.5

UPDATE

如果pass语句是程序的最后一行,并且有一个断点,则调试器将停在该pass语句处.我知道它已停止,因为我可以看到当前的堆栈跟踪和变量.

但是,如果pass不是最后一行,调试器将不会停在那里.

Dav*_*ver 6

调试器不会在pass语句中断.您可以通过在其后添加语句来验证这一点:

$ cat test.py
if True:
  print 'here'
else:
  print 'there'
  pass  # breakpoint here
print 'done'
$ python -m pdb test.py
> test.py(1)<module>()
-> if True:
(Pdb++) list
  1  -> if True:
  2       print 'here'
  3     else:
  4       print 'there'
  5       pass  # breakpoint here
  6     print 'done'
[EOF]
(Pdb++) break 5
Breakpoint 1 at test.py:5
(Pdb++) continue
here
done
The program finished and will be restarted
Run Code Online (Sandbox Code Playgroud)

调试器似乎在那里打破,因为它是文件中的最后一行?