[Python-Dev] PEP 553: Built-in debug() (original) (raw)
Nathaniel Smith njs at pobox.com
Tue Sep 5 22:58:46 EDT 2017
- Previous message (by thread): [Python-Dev] PEP 553: Built-in debug()
- Next message (by thread): [Python-Dev] PEP 553: Built-in debug()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Sep 5, 2017 at 6:14 PM, Barry Warsaw <barry at python.org> wrote:
I’ve written a PEP proposing the addition of a new built-in function called debug(). Adding this to your code would invoke a debugger through the hook function sys.debughook().
The 'import pdb; pdb.set_trace()' dance is extremely obscure, so replacing it with something more friendly seems like a great idea.
Maybe breakpoint() would be a better description of what set_trace() actually does? This would also avoid confusion with IPython's very useful debug magic: https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-debug and which might also be worth stealing for the builtin REPL. (Personally I use it way more often than set_trace().)
Example:
In [1]: def f(): ...: x = 1 ...: raise RuntimeError ...:
In [2]: f()
RuntimeError Traceback (most recent call last) in () ----> 1 f()
in f() 1 def f(): 2 x = 1 ----> 3 raise RuntimeError
RuntimeError:
In [3]: debug
(3)f() 1 def f(): 2 x = 1 ----> 3 raise RuntimeError
ipdb> p x 1
-n
-- Nathaniel J. Smith -- https://vorpus.org
- Previous message (by thread): [Python-Dev] PEP 553: Built-in debug()
- Next message (by thread): [Python-Dev] PEP 553: Built-in debug()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]