Python has several interactive shells (aka. REPLs) that you can use to explore Python directly and you can also tell python that a certain point in your application it will enter the REPL and allow you to discover things from that point.

ptpython is such a REPL.

pip install ptpython

Then I used the following code:

examples/debug_with_ptpython.py

import requests
from ptpython.repl import embed

res = requests.get("https://code-maven.com/")
embed(globals(), locals())

print("done")

Debug with PTPython