🖥

#python で #ruby の binding.pry みたいなことがやりたい ( IPython InteractiveShellEm

2019/04/18に公開
  • continue が効かない
  • next はなんか違う
  • exit で次に行けそう

script

#!/usr/bin/env python3
from IPython.terminal.embed import InteractiveShellEmbed
for i in range(5):
  ipshell = InteractiveShellEmbed()
  ipshell()

exe

Python 3.7.2 (default, Jan 13 2019, 12:50:01)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: i
Out[1]: 0
In [2]: i
Out[2]: 0
In [3]: continue
  File "<ipython-input-3-6ca52a340915>", line 4
SyntaxError: 'continue' not properly in loop

In [4]: break
  File "<ipython-input-4-6aaf1f276005>", line 4
SyntaxError: 'break' outside loop

In [5]: next
Out[5]: <function next>
In [6]: i
Out[6]: 0
In [7]: i
Out[7]: 0
In [8]: exit
Python 3.7.2 (default, Jan 13 2019, 12:50:01)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: i
Out[1]: 1
In [2]: exit
Python 3.7.2 (default, Jan 13 2019, 12:50:01)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: i
Out[1]: 2
In [2]: exit
Python 3.7.2 (default, Jan 13 2019, 12:50:01)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: i
Out[1]: 3
In [2]:

ref

Pythonの実行中にインタラクティブシェルを起動する - Qiita

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/1315

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-04-18

Discussion