Embedding an IPython shell in C / C ++ - program

I have C ++ - a program that allows me to run Python scripts with which C ++ passes data. If the Python script does not work, the C ++ program calls PyRun_InteractiveLoop to resolve the problem in the interactive shell. This works well, but I thought: β€œIt would be great if IPython were installed, I could use it in this case.”

Now my problem: all I find when looking for "embed ipython" is instructions for embedding IPython in Python programs (among others http://ipython.org/ipython-doc/dev/interactive/reference.html#embedding -ipython ). I tried to play them on the python built-in regular shell, but most of them crash in some way (usually due to the lack of sys.argv .... one that I can solve).

Any suggestions on how to do this? My first plan was to import IPython first through the C-API (the one I received). If it fails to use the "regular" shell. Otherwise, call IPython.embed () (or similar) via PyRun_InteractiveOneFlags

+7
source share
1 answer

Do you consider using a python debugger

>>> import pdb >>> import yourmodule >>> pdb.run('yourmodule.test()') 
0
source

All Articles