Giving interactive control of a Python program to the user

183 Views Asked by At

I need my Python program to do some stuff, and at a certain point give control to the user (like a normal Python shell when you run python3 or whatever) so that he can interact with it via command line. I was thinking of using pwntools's interactive() method but I' m not sure how I would use that for the local program instead of a remote.

How would I do that?

Any idea is accepted, if pwntools is not needed, even better.

1

There are 1 best solutions below

0
On

Use IPython

If you haven't already, add the package IPython using pip, anaconda, etc.

Add to your code:

from IPython import embed

Then where you want a "breakpoint", add:

embed()

I find this mode, even while coding to be very efficient.