Text-based data inspector for Python?
socyl at 987jk.com.invalid
Fri Jan 25 15:28:08 CET 2008
In <mailman.1057.1201222869.896.python-list at python.org> Terry Jones <terry at jon.es> writes:
>>>>>> "kj" == kj <socyl at 987jk.com.invalid> writes:
>You actually liked the perl debugger... gasp!
Still do, in fact!.
>OK, I used it too, but it
>left a few things to be desired...
I'd love to read your thoughts on the matter. My biggest complain
about it is that its underlying code is very poorly designed and
it's having a difficult time keeping up with the language. With
each new version of Perl it springs new leaks, unfortunately. For
example, it's much worse than Perl itself at dealing with Unicode.
...And its documentation is probably the worst of all of the core
Perl docs. Let's see, what else...? Nothing else comes to mind
at the moment.
>I use M-x pydb to debug python from inside emacs. I like it more than the
>straight pdb as it's a bit more like gdb.
>In pydb (and pdb) there's p and pp to print and pretty print a python
>object. They work pretty well & there's no need for the mouse.
Thank you much for the tip. I just skimmed over its documentation
and I'm looking forward to using it. The one thing I couldn't
find, and would greatly miss if not available, is the ability to
set breakpoints by inserting a particular indication right in the
code. In the Perl debugger one can insert something like the
following anywhere in the code:
$DB::single = 1;
When such a line executes, the debugger immediately switches to
single-step mode. It's a very flexible technique, and I like it
a lot more than setting breakpoints the "usual" way (i.e. "b [line]
[condition]"). For example, for a conditional breakpoint one can
do something like:
$DB::single = some_boolean_test();
Or if one isn't sure exactly when one wants to stop at the location,
one can just write:
$DB::single = ( $::SOME_GLOBAL_VARIABLE || 0 );
(The "|| 0" is there so that the debugger won't complain over
assigning an undefined RHS in the assignment.) If while stopped
at some other breakpoint, and perhaps having inspected some data,
we decide that it's time to stop at this line, we just assign 1 to
the global, hit the old "c"(ontinue), and one's there.
In fact, setting $DB::single is the only way I know to have a
breakpoint in code that executes at compile time (such as anything
in a BEGIN block and any top-level code in modules imported via
the "use" directive). Setting a breakpoint with b at such points
and restarting the program won't work. Extremely handy.
Maybe something like this (or even better!) is already possible in
pydb, but I couldn't find it. If it is, though, I'll be very
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
More information about the Python-list