Spawning an interactive interpreter in a running python process?
Tim Chase
python.list at tim.thechases.com
Fri Dec 11 23:49:33 EST 2009
> I'm curious, in an academic sense, if it's possible to spawn the
> interactive interpreter (>>>) in a running python application. Ideally, I
> would like to be able to access the modules, functions and variables the
> application can.
>
> Is something like this possible?
While not exactly "the interactive interpreter", you can use pdb
to drop to a debugging prompt where you can "access the modules,
functions and variables the application can". The common idiom
is to insert a line like
import pdb; pdb.set_trace()
in your code to have a break-point stop execution at the
designated point and leave you at a prompt where you can explore.
-tkc
More information about the Python-list
mailing list