I ran accross this today. rfoo allows connecting to a remote running session of python and inspect the session's values, modify the data, etc.
You can read more about it
here
Install in ubuntu:
sudo apt-get install python-dev
pip install cython
pip install rfoo
rconsole is a remote Python console with auto completion, which can be used to inspect and modify the namespace of a running script.
To invoke in a script do:
from rfoo.utils import rconsole
rconsole.spawn_server()
To attach from a shell do:
rconsole