On Thu, 21 Feb 2008 10:01:56 -0500, Barry Warsaw <[EMAIL PROTECTED]> wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >I know this will get shot down like a Navy missile aimed at an errant >spy satellite, but I'm going to suggest it anyway. > >Several of us have been talking about merging the two Emacs Python >modes and this prompted a discussion of Ken Manheimer's excellent >pdbtrack hack, which got me thinking about the way I use pdb. I don't >know if this is typical or unique, or whether anyone else is annoyed >the same way I am. Admittedly it's a minor annoyance, but I still >think we can do better. > >So I have some particularly troublesome code that I want to set a >breakpoint at and start stepping through. I usually will stick this >tidbit at the place I want to break: > > good_code() > import pdb; pdb.set_trace() > call_buggy_code()
I do this all the time, too. Basically any time I need to use a debugger to fix something. > >In doctests it's a little ickier because I have to put that all on the >line where I want to break, not before it or doctest won't do the >right thing, e.g.: > > >>> import pdb; pdb.set_trace(); call_buggy_code() > >I suggest that setting a breakpoint be done with a new built-in, e.g >breakpoint(). So now I would do this: > > good_code() > breakpoint() > call_buggy_code() > >or > > >>> breakpoint(); call_buggy_code() > >Yes, all it saves me is an import, but it also elevates debugging to a >more important, and more visible location. > >Okay, so now that I've convinced you this is the most brilliant idea >this century <wink>, I'm really going to smoke some crack. > >The other thing this should do is allow us to use different debuggers >if we wanted. Maybe today breakpoint() would call into pdb, but maybe >tomorrow we'll have a better debugger, or someone will have installed >a better debugger in site-packages (e.g. pydb). I would suggest that >breakpoint() consult an environment variable such as PYTHONDEBUGGER to >see which debugger to invoke (the first time in a session only of >course). Perhaps you could also set PYTHONDEBUGGER=ignore to noop any >and all calls to breakpoint. Maybe there's a python command line >switch to mirror $PYTHONDEBUGGER. > >trying-not-to-spray-hydrazine-all-over-you-ly y'rs, >- -Barry Wouldn't a less invasive solution be to make pdb better? In particular, to make `breakpoint´ actually reliably set a breakpoint? Jean-Paul _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com