Can I use IPython in an embedded interactive Python console?

后端 未结 2 1791
孤城傲影
孤城傲影 2021-02-04 17:08

I use the following snippet to drop into a Python shell mid-program. This works fine, but I only get the standard console. Is there a way to do the same but using the IPython sh

相关标签:
2条回答
  • 2021-02-04 17:54

    The answer by f3lix is no longer valid it seems, I was able to find this however:

    At the top of your python script:

    from IPython import embed
    

    Wherever you want to spin up a console:

    embed()
    
    0 讨论(0)
  • 2021-02-04 17:56

    Embedding IPython might be interesting for you.

    Mininum of code to run IPython in your app:

    from IPython.Shell import IPShellEmbed
    ipshell = IPShellEmbed()
    ipshell() # this call anywhere in your program will start IPython 
    
    0 讨论(0)
提交回复
热议问题