pdb.set_trace may not seem long

Proposal: pdb.st = pdb.set_trace ----------- I find myself typing this a lot: import pdb;pdb.set_trace() It's the int3 of python. When I want to debug an exact point in the code I use the above line. I hope I don't come off as spoiled, it's just that import pdb;pdb.pm() is so short that I can't help but wonder how better my life would be if I could do: import pdb;pdb.st() What do you guys think? I know aliasing isn't cool since TSBOAPOOOWTDI but practicality beats purity.... Yuval

Yuval Greenfield schrieb am Mon, 09. Apr 2012, um 17:20:22 +0300:
I find myself typing this a lot:
import pdb;pdb.set_trace()
What I do instead: I start pdb in Emacs, set a break point on the line and run the script. This should work in any other interactive debugger for Python, too. If for some reason you prefer to insert the above-mentioned line into your source code, how about defining an editor macro for this purpose, so you could do it with a single shortcut? Cheers, Sven

I think this is unnecessary; if you find yourself typing that so much, create a module with a one-letter name and put a bunch of one-letter convenience functions in it. Or figure out how to create macros for your editor. On Mon, Apr 9, 2012 at 7:20 AM, Yuval Greenfield <ubershmekel@gmail.com> wrote:
-- --Guido van Rossum (python.org/~guido)

On Mon, Apr 9, 2012 at 9:13 PM, Guido van Rossum <guido@python.org> wrote:
On the other side it is an import intended to debug side effects. Syntax sugar that makes debugging in Python more intuitive. I always land on stackoverflow when I need to recall the structure of this pdb import call. In ideal world it would be even something like: import debug.start but of course, a builtin debug() which calls registered debugger for an application or pdb (by default) could be even more shorter and easy for newbies at the cost of added magic.
This also won't work if pdb.trace was imported before.
Can pdb.trace remove itself from sys.modules while being imported?

Yuval Greenfield schrieb am Mon, 09. Apr 2012, um 17:20:22 +0300:
I find myself typing this a lot:
import pdb;pdb.set_trace()
What I do instead: I start pdb in Emacs, set a break point on the line and run the script. This should work in any other interactive debugger for Python, too. If for some reason you prefer to insert the above-mentioned line into your source code, how about defining an editor macro for this purpose, so you could do it with a single shortcut? Cheers, Sven

I think this is unnecessary; if you find yourself typing that so much, create a module with a one-letter name and put a bunch of one-letter convenience functions in it. Or figure out how to create macros for your editor. On Mon, Apr 9, 2012 at 7:20 AM, Yuval Greenfield <ubershmekel@gmail.com> wrote:
-- --Guido van Rossum (python.org/~guido)

On Mon, Apr 9, 2012 at 9:13 PM, Guido van Rossum <guido@python.org> wrote:
On the other side it is an import intended to debug side effects. Syntax sugar that makes debugging in Python more intuitive. I always land on stackoverflow when I need to recall the structure of this pdb import call. In ideal world it would be even something like: import debug.start but of course, a builtin debug() which calls registered debugger for an application or pdb (by default) could be even more shorter and easy for newbies at the cost of added magic.
This also won't work if pdb.trace was imported before.
Can pdb.trace remove itself from sys.modules while being imported?
participants (5)
-
anatoly techtonik
-
Guido van Rossum
-
Ned Batchelder
-
Sven Marnach
-
Yuval Greenfield