« Back to Index

Python equivalent to Ruby’s Pry (update: use https://docs.python.org/3/library/pdb.html - see also https://pythonconquerstheuniverse.wordpress.com/2009/09/10/debugging-in-python/)

View original Gist on GitHub

Python equivalent to Ruby’s Pry.md

Basic

import code; code.interact(local=locals())

Advanced

IPython with embed()

Install it with:

pip install ipython

Use it like so:

from IPython import embed

# Misc code

embed() # this will drop us into IPython

# Misc code

Although you can use it directly as well:

import IPython

x = "foo"
print(x)

IPython.embed()

x = "bar"
print(x)