Interactive interpreter in embedded Python

arnd.baecker at physik.uni-ulm.de arnd.baecker at physik.uni-ulm.de
Mon May 6 03:35:34 EDT 2002


Hi,

I think you should have a look at IPython,
  http://www-hep.colorado.edu/~fperez/ipython/
With this you can do things like the following in your program

#--------- call ipython to get an interactive prompt
from IPython.Shell import IPythonShellEmbed
ipshell=IPythonShellEmbed()

a=10
ipshell()      # open IPython (possible anywhere in the code)
b=20
ipshell()      # ... and as many times as you want ...
#---------

at any place within your programm.
You'll find several further examples and details in sec. 7
("Embedding IPython in other programs") of the excellent
documentation.

Apart from this IPython is a really great python shell with _many_
enhancements over the normal python prompt.
(in the longer run the idea is that it can be used within
other programs like IDLE, etc...).

Arnd


On Sat, 4 May 2002, Bjarke Dahl Ebert wrote:

> Hello,
>
> When you write a Python extension in C(++), it is very easy to play with it
> from the shell. Just open an interactive interpreter and import the
> extension module.
>
> But what if you have an application embedding a Python interpreter? Then it
> would also be nice, at least during development, to be able to get a "Python
> prompt" to play with functions exported from the application, etc.
>
> So, after calling Py_Initialize and initializing my Python extensions, what
> is the easiest way to open a Python Shell in a window?
> I'm programming in Win32. Either IDLE or PythonWin would be fine.
>
> If the C application is (natively) graphical, will I get problems with
> IDLE/PythonWin interfering with the message handling loop of the
> application?
>
>
> Kind regards,
> Bjarke
>
>
>
>
>






More information about the Python-list mailing list