Source From Here
Question
I used b "classname:function" or "b classname::function", and those didn't work. now I use "b linenum" as a workaround.but as I modifiy my code frequently, linenum changes.So how to make a breakpoint on class member function in python? I google it && read the python manual, and there's no direct answer.thanks!
How-To
In pdb, the Python debugger, the breakpoint can be set with:
* b(reak) [[filename:]lineno | function[, condition]]
* b(reak) classname.methodname
For example,
Setting the breakpoint before parsing the class fails:
but after parsing the class:
setting the breakpoint works:
Question
I used b "classname:function" or "b classname::function", and those didn't work. now I use "b linenum" as a workaround.but as I modifiy my code frequently, linenum changes.So how to make a breakpoint on class member function in python? I google it && read the python manual, and there's no direct answer.thanks!
How-To
In pdb, the Python debugger, the breakpoint can be set with:
* b(reak) [[filename:]lineno | function[, condition]]
* b(reak) classname.methodname
For example,
- % pdb ~/pybin/test.py
- > /home/unutbu/pybin/test.py(4)
() - -> class Foo(object):
- (Pdb) l
- 1 #!/usr/bin/env python
- 2 # coding: utf-8
- 3
- 4 -> class Foo(object):
- 5 def bar(self): pass
- 6
- 7 foo=Foo()
- 8 foo.bar()
- [EOF]
- (Pdb) b Foo.bar
- *** The specified object 'Foo.bar' is not a function
- or was not found along sys.path.
- (Pdb) n
- > /home/unutbu/pybin/test.py(7)
() - -> foo=Foo()
- (Pdb) l
- 2 # coding: utf-8
- 3
- 4 class Foo(object):
- 5 def bar(self): pass
- 6
- 7 -> foo=Foo()
- 8 foo.bar()
- [EOF]
- (Pdb) b Foo.bar
- Breakpoint 1 at /home/unutbu/pybin/test.py:5
- (Pdb)
- (Pdb) r
- > /home/unutbu/pybin/test.py(5)bar()
- -> def bar(self): pass
沒有留言:
張貼留言