-----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() 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBR72SZXEjvBPtnXfVAQK7gwP7BKyIMAarMZEPzTQVfR/W8J4KzBEQFhtj 3pLd83I8oQMgP4SD0BapiJZ2BOws3i2TAZ501V8VF8iR50nyNGTYCP4pJ/sy6Cr0 Q79ahrvKq5+eS/17+Zi/c/yC028h585m1pvg9/VALu1decLvz3m6UPxJWsZJ+ldw Qj5bUtuCJ7c= =YBMp -----END PGP SIGNATURE----- _______________________________________________ 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