简体   繁体   中英

Can I make pdb start debugging right away?

I want to debug a python project

The problem is, I don't know where to set a break point,

what I want to do, is be able to call a method

SomeClass( some_ctor_arguments ).some_method()` 

and have the debugger be fired right away

How do I do that?

I tried pdb.run( string_command ) but it doesn't seem to work right

>>> import pdb
>>> import <some-package>
>>> pdb.run( .... )
> <string>(1)<module>()
(Pdb) s
NameError: "name '<some-package>' is not defined"

Found it..

pdb.runcall( object.method )
pdb.set_trace()

will start the debugger at this point.

Place it at the beginning of the method you want to debug.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM