paste this inside your script for debugging, to start a Python interactive terminal shell session at that point in the script, super useful for debugging since it lets you explore the Python environment and access objects and variables as they are at that point in the script.
import readline # optional, will allow Up/Down/History in the console
import code
vars = globals().copy()
vars.update(locals())