Reputation: 1181
we often come across python examples like
>>> some python instruction 1
some python instruction 1 (expected) output
>>> some python instruction 2
some python instruction 2 (expected) output
and we have to copy-paste it in console, because, say, ide debugger doesn't print for us what console does, like the result of current instruction.
Is there a tool to do the job? May be some ide plugin could be configured to parse >>> instructions strings and show output in the console to verify proposed - actual results?
Upvotes: 2
Views: 5442
Reputation: 76867
You can use the pdb
module to do that.
Basically, import pdb; pdb.set_trace()
would allow you to execute your code line by line. The debugger is interactive, and it allows you to print values, set new variables, use them, and step into functions if you need and so on.
Upvotes: 1