Run your python code with the flag -i
to drop into an interactive session automatically at the end of program execution, with all objects still intact:
$ python -i script.py
[output]
>>>
You can also add a breakpoint to your script using pdb.set_trace()
:
pdb.set_trace()