Dans IPython 0.11, vous pouvez intégrer IPython directement dans votre code comme ceci
Votre programme pourrait ressembler à ceci
In [5]: cat > tmpf.py
a = 1
from IPython import embed
embed() # drop into an IPython session.
# Any variables you define or modify here
# will not affect program execution
c = 2
^D
Voici ce qui se passe lorsque vous l'exécutez (j'ai choisi arbitrairement de l'exécuter à l'intérieur d'une session ipython existante. D'après mon expérience, l'imbrication des sessions ipython peut provoquer un plantage).
In [6]:
In [6]: run tmpf.py
Python 2.7.2 (default, Aug 25 2011, 00:06:33)
Type "copyright", "credits" or "license" for more information.
IPython 0.11 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: who
a embed
In [2]: a
Out[2]: 1
In [3]:
Do you really want to exit ([y]/n)? y
In [7]: who
a c embed