LoginSignup
58
41

More than 5 years have passed since last update.

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

Posted at

Rubyのbinding.pryをPythonでもやりたいと思ったらありました。

# coding: utf-8

from IPython import embed
from IPython.terminal.embed import InteractiveShellEmbed


n = 1

print('start embed')
embed()

# === ipython interactive shell ===
#
# print(n)
# => 1
#
# n += 1
#
# Ctrl + D : exit ipython
print('end embed')


ipshell = InteractiveShellEmbed()

print('start interactive shell')
ipshell()

# === ipython interactive shell ===
#
# print(n)
# => 2
#
# Ctrl + D : exit ipython
print('end interactive shell')

便利情報でした。
短いですが、こちらからは以上です。

58
41
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
58
41