[Python-Dev] PEP 553: Built-in debug()

Barry Warsaw barry at python.org
Tue Sep 5 21:14:12 EDT 2017


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().

Like the existing sys.displayhook() and sys.excepthook(), you can change sys.debughook() to point to the debugger of your choice.  By default it invokes pdb.set_trace().

With this PEP instead of:

    foo()
    import pdb; pdb.set_trace()
    bar()

you can write:

    foo()
    debug()
    bar()

and you would drop into the debugger after foo() but before bar().  More rationale and details are provided in the PEP:

    https://www.python.org/dev/peps/pep-0553/

Unlike David, but like Larry, I have a prototype implementation:

    https://github.com/python/cpython/pull/3355

Cheers,
-Barry

P.S. This came to me in a nightmare on Sunday night, and the more I explored the idea the more it frightened me.  I know exactly what I was dreaming about and the only way to make it all go away was to write this thing up.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 273 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170905/05e7e169/attachment.sig>


More information about the Python-Dev mailing list