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.

Attachment: signature.asc
Description: Message signed with OpenPGP

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to