[Python-Dev] PEP 553: Built-in debug()
Nathaniel Smith
njs at pobox.com
Tue Sep 5 22:58:46 EDT 2017
More information about the Python-Dev mailing list
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) <ipython-input-2-0ec059b9bfe1> in <module>() ----> 1 f() <ipython-input-1-db0dc90ff5b9> in f() 1 def f(): 2 x = 1 ----> 3 raise RuntimeError RuntimeError: In [3]: debug > <ipython-input-1-db0dc90ff5b9>(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 ]
More information about the Python-Dev mailing list