(original) (raw)

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@pobox.com> wrote:
On Tue, Sep 5, 2017 at 6:14 PM, Barry Warsaw <barry@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
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
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/guido%40python.org



--
--Guido van Rossum (python.org/\~guido)