On Tue, Sep 5, 2017 at 6:14 PM, Barry Warsaw <[email protected]> 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
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com