This Engineering Notebook post rethinks what Leo's IPython bridge (in *leoIPython.py*) must be.
Leo's IPython bridge has likely not worked for years. Imo, the bridge has never been much more than a toy. As a result, I feel free to re-imagine everything about Leo's relationship to IPython. *Goals and requirements* *I'll retire leoIPython.py unless Leo can become an easy-to-use IPython notebook. * - Leo and IPython must run without blocking each other. - IPython must have access to c, g and p. *Managing event loops* As an experiment, I tried running this Leonine script: import IPython IPython.embed() As expected, this script starts IPython in the console window from which Leo launched. And IPython does have access to c, g and p! In [1]: c Out[1]: Commander 1439643722256: 'c:/Repos/leo-editor/leo/core/leoPy.leo' In [2]: g Out[2]: <module 'leo.core.leoGlobals' from 'C:\\Repos\\leo-editor\\leo\\core\\leoGlobals.py'> In [3]: p Out[3]: <pos 1439662055744 childIndex: 6 lvl: 0 key: 1439726600784:6 embed> Alas, Leo hangs until IPython quits. So more work is needed :-) *Managing namespaces* A new Leo command, *execute-ipython-script*, should execute p.b in a namespace that includes all names known to the running IPython instance. Similarly, IPython must have access to c, g and p *without *using embed. *Packaging* Leo's present *--ipython* command-line arg starts Leo in a ipython console window. I would like to retire this arg: it's clumsy and adds nothing essential. Instead, a new Leo command, say *launch-ipython*, would: - Exit with a warning if importing ipython fails. - Launch (once) IPython in the console from which Leo was launched. *Summary* Leo's IPython bridge is little more than a toy. Worse, leoIPython.py has not worked for years. I shall retire leoIPython.py unless Leo can become a straightforward, easy-to-use IPython notebook. This notebook must: - block neither IPython nor Leo. - give IPython access to c, g and p. - have an execute-ipython-script command. It remains an open question whether these goals are attainable. I have hopes: IPython's API (fully accessible from Leo) has many features relating to embedding IPython into applications. All comments and questions are welcome. Edward P.S. Running Leo from Leo's bridge is not the answer. We could avoid clashing event loops by embedding Leo's bridge (in *leoBridge.leo*) into IPython. But giving IPython access to Leo via Leo's bridge would add almost nothing to IPython! EKR -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/86b78925-ae47-4fc0-a5f3-3ca2f78e5983n%40googlegroups.com.
