[IPython-dev] pycolor: read from STDIN

Paul Mueller gakusei at dakotacom.net
Thu May 10 23:13:35 EDT 2007


Hello,

IPython/PyColorize.py currently doesn't support reading from STDIN when
used from the command line. It would be useful for such things as
coloring the output of svn cat, calling pycolor from scripts (perhaps
not written in python) or programs, grep (sometimes), etc.

Should I submit a patch to add this? If so, I have a question: should
the command-line interface require a "-" in place of the filename to
mean read from STDIN, or should it read from STDIN if "-" or no filename
is given?

I think the later is better, because it is easy to forget the "-":

svn cat -r5 file | pycolor
is easier than
svn cat -r5 file | pycolor -

However, this would change pycolor's current behavior of printing the
help message if no filename is given (I would add a -h/--help option
instead).

I'm also open to rewriting the option parsing to use optparse (or
DPyGetOpt), as per the FIXME comment in main(); I think this would be
preferable to extending the current ad hoc parsing code.

Paul Mueller



More information about the IPython-dev mailing list