How can I start REPL at the end of python script for debugging? In Node I can do something like this:
code;
code;
code;
require('repl').start(global);
Is there any python alternative?
If you execute this from the command prompt, just use -i
:
➜ Desktop echo "a = 50" >> scrpt.py
➜ Desktop python -i scrpt.py
>>> a
50
this invokes Python after the script has executed.
Alternatively, just set PYTHONINSPECT
to True
in your script:
import os
os.environ['PYTHONINSPECT'] = 'TRUE'
Just use pdb (python debugger)
import pdb
print("some code")
x = 50
pdb.set_trace() # this will let you poke around... try "p x"
print("bye")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With