开发者

Breaking at a member function in the Python debugger

This should be a trivial question, but my search so far has been fruitless:

I'm using the Python debugger (pdb) for the first time, and was quite pleased to find most of the commands familiar from using gdb.

However, when I went to set a breakpoint in the parse() member of class JamParser with the statement:

(Pdb) b JamParser.parse
*** The specified object 'JamParser.parse' is not a function
or was not found along sys.path.

I tried several several variants, including:

(Pdb) b jam2dot.py:JamParser.parse

I assume that since I invoked the debugger from the command line that it knows the entities in the file. Is that 开发者_运维问答a false assumption?

The documentation says that break can take a function as an argument, but doesn't offer any syntax help. So how do I set a breakpoint for a member function by name?


You need to import names before you can refer to them in the debugger.

(Pdb) from jam2dot import JamParser
(Pdb) b JamParser.parse
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜