[IPython-user] Colorizing lines in debuggers and post-mortem
Sun Feb 18 17:02:51 CST 2007
On Sat, Feb 17 2007, R. Bernstein wrote:
> Fernando Perez writes:
> > On 2/14/07, R. Bernstein <email@example.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.
> > >
> > 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.....
> I had a little bit of time and played around with this. The
> simple-minded solution of calling tokenize.tokenize() and reporting
> back a failure, seems to work pretty well in the cases I
> tried. Although I make no claim for elegance here, it's also not that
> complex or that many changes either.
> Below is a patch. But it is not really a proper patch for reasons
> listed below. It's more intended for folks to try out to get feedback.
> I think it helps; and in complicated cases where there are
> continuation lines and comments, it's no worse that what's currently
> there. But I'm not all that enthralled with the choice of colors. THe
> reserved words for LightBG is green -- almost the same as for line
> numbers. GNU emacs uses purple. And for comments GNU emacs uses brown
> which I think a little better than red.
> Here's why the patch isn't ideal. First, it encorporates some of the
> previous unapplied patches which are needed at least to see this via
> %pydb. Since I liked this idea (aside from the color selections) and
> wanted to see what go further, I also made a change to UltraTB.py.
> Here I basically a copied of the same 4 or so lines added to
> Debugger.py, and since I couldn't figure out how to get the current
> color scheme in effect, I just hard-coded what I use: 'LightBG'.
> I'm curious to hear comments from others.
First attempted in console - black on black is hard to read :)
I liked the idea of this, but the combination of coloured IPython chrome and
a limited choice of colours made things harder for me to read then without.
Maybe with a careful selection of colours it could work, but when I'm only
looking at a handful of lines, it makes it hard to focus.
Oh, and I think you've got a typo - an extra self.
,----[ PyColorize.py: 124 ]
| def format(self, raw, out = None, scheme = ''):
| return self.format2(self, raw, out, scheme)
More information about the IPython-user