程序执行到这里后,等待输入python命令
最好可以保存上下文信息,能够随时退出
考虑单文件的情况,最好在进入断点时相当于把文件的前一部分手动输入repl
<code class="language-pycon"><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">code</span> <span class="gp">>>> </span><span class="k">def</span> <span class="nf">x</span><span class="p">():</span> <span class="gp">... </span> <span class="n">a</span> <span class="o">=</span> <span class="mi">1</span> <span class="gp">... </span> <span class="n">code</span><span class="o">.</span><span class="n">interact</span><span class="p">(</span><span class="n">banner</span><span class="o">=</span><span class="s">""</span><span class="p">,</span><span class="n">local</span><span class="o">=</span><span class="nb">locals</span><span class="p">())</span> <span class="gp">... </span> <span class="gp">>>> </span><span class="n">x</span><span class="p">()</span> <span class="gp">>>> </span><span class="n">a</span> <span class="go">1</span> <span class="go">>>></span> </code>
<code class="language-python3"><span class="kn">from</span> <span class="nn">IPython</span> <span class="k">import</span> <span class="n">start_ipython</span> <span class="n">start_ipython</span><span class="p">()</span> </code>
<code class="language-python3"><span class="kn">import</span> <span class="nn">code</span> <span class="n">code</span><span class="o">.</span><span class="n">interact</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">banner</span><span class="p">,</span> <span class="n">local</span><span class="o">=</span><span class="n">context</span><span class="p">)</span> </code>
<code class="language-python"><span class="kn">import</span> <span class="nn">IPython</span> <span class="n">IPython</span><span class="o">.</span><span class="n">embed</span><span class="p">()</span> </code>
<code class="language-text">from ptpython.repl import embed embed(globals(), locals(), vi_mode=False, history_filename=None) </code>