2

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?

Community
  • 1
  • 1
WebComer
  • 1,131
  • 2
  • 19
  • 31

1 Answers1

1

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.

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
  • In fact i want to "run" .txt file from say, some book or tutorial. The tool is to parse >>> instructions and to show their output in separate window. – WebComer Oct 16 '15 at 15:00
  • (a kind of ipython notebook or jupyther without converting to .ipnb files). – WebComer Oct 16 '15 at 15:44