Is there a way to make python become interactive in the middle of a script?

后端 未结 6 977
执笔经年
执笔经年 2021-02-01 07:03

I\'d like to do something like:

do lots of stuff to prepare a good environement
become_interactive
#wait for Ctrl-D
automatically clean up

Is i

6条回答
  •  北海茫月
    2021-02-01 07:48

    With IPython v1.0, you can simply use

    from IPython import embed
    embed()
    

    with more options shown in the docs.

提交回复
热议问题