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

Guido van Rossum guido at python.org
Tue Sep 5 23:15:46 EDT 2017


Yeah, I like the idea, but I don't like the debug() name -- IIRC there's a helper named debug() in some codebase I know of that prints its arguments under certain circumstances.

On Tue, Sep 5, 2017 at 7:58 PM, Nathaniel Smith <njs at pobox.com> wrote:

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


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ guido%40python.org

-- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170905/8f1ba0ef/attachment.html>



More information about the Python-Dev mailing list