Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

start interactive mode on a specific script line

I need to run my Python script as usual, but I want to stop execution on a specific line and start interactive mode.

In other words, I want to be able to check the value of all my variables at that point, and continue myself from there on python's command line.

How can I do this?

like image 920
Ricky Robinson Avatar asked Aug 03 '12 13:08

Ricky Robinson


2 Answers

This can be done with the code module. The easiest way is to call code.interact().

like image 147
Sven Marnach Avatar answered Sep 19 '22 15:09

Sven Marnach


Use a debugger and add breakpoints. Do you use an IDE? All the major IDEs have debugger support. From the CLI, you can use pdb.

like image 34
Silas Ray Avatar answered Sep 18 '22 15:09

Silas Ray