Last active
November 4, 2022 08:09
-
-
Save gh640/5d266954e691fe5eee7fb857b65a9eee to your computer and use it in GitHub Desktop.
Running IPython or bpython with `breakpoint()` on Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/bash | |
# Use IPython. | |
PYTHONBREAKPOINT=IPython.terminal.debugger.set_trace python myscript.py | |
# Use bpython. | |
PYTHONBREAKPOINT=bpdb.set_trace python myscrippt.py |
The related PEP is PEP 533.
https://www.python.org/dev/peps/pep-0553/#id11
PYTHONBREAKPOINT=some.importable.callable
. In this case,sys.breakpointhook()
imports the some.importable module and gets thecallable
object from the resulting module, which it then calls. The value may be a string with no dots, in which case it names a built-in callable, e.g.PYTHONBREAKPOINT=int
. (Guido has expressed the preference for normal Python dotted-paths, not setuptools-style entry point syntax.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
IPython
IPython.terminal.debugger.set_trace()
:https://github.com/ipython/ipython/blob/master/IPython/terminal/debugger.py
bpython
bpdb.set_trace()
:https://github.com/bpython/bpython/blob/main/bpdb/__init__.py