[IPython-user] Colorizing lines in debuggers and post-mortem

Fernando Perez fperez.net@gmail....
Wed Feb 14 14:28:28 CST 2007


On 2/14/07, R. Bernstein <rocky@panix.com> wrote:
> When looking at the colorized debugger output, there something I think
> a little odd. IPython has a colorize routine for Python programs.  I'm
> referring to PyColorize.Parse.format here.  But format is not used in
> these listings, even though IPython also has a customized debugger
> "list" method.
>
> I guess the problem has to do with getting *fragments* of Python which
> you may get in a single line of Python code. The tokenization routine
> might return an error. Note though that most Python code is properly
> formatted when looked at on a line by line basis.
>
> I think that if the format method's interface were changed slightly,
> IPython could show program in debuggers and post-mortem
> better. Instead of format writing to the output some sort of error
> message when a line is malformed (or more likely incomplete), if it
> returned an error status or raised an exception the caller could take
> appropriate action.
>
> Assuming a change like this, here's how I think a listing would
> work. You call format on a line or range of lines, if that there's no
> error you accept the formatted output. Otherwise you just print the
> line as is (which is what is being done now).

Sure, I don't see a problem with that, and I'd be happy to apply such
a patch.  As long as you test it with things like


"""foo.....

being the last line of input (a typical case that would give
tokenization problems, being an unterminated string), we'll gladly
apply it.

The debugging support in ipython is admittedly rather minimal, and has
really only improved significantly thanks to user contributions (such
as yours).

I'll also try to catch up on the recent patches in a couple of days.

Cheers,

f


More information about the IPython-user mailing list