Raw strings as input from File?
rzantow at gmail.com
Wed Dec 2 02:22:46 CET 2009
utabintarbo <utabintarbo at gmail.com> wrote in
news:adc6c455-5616-471a-8b39-d7fdad2179e4 at m33g2000vbi.googlegroups.c
> I have a log file with full Windows paths on a line. eg:
> \somerandomfilename.ext ; t9999xx; 11/23/2009 15:00:16 ;
> As I try to pull in the line and process it, python changes the
> "\10" to a "\x08". This is before I can do anything with it. Is
> there a way to specify that incoming lines (say, when using
> .readlines() ) should be treated as raw strings?
Despite all the ragging you're getting, it is a pretty flakey thing
that Python does in this context:
(from a python shell)
>>> x = '\1'
>>> x = '\10'
If you are pasting your string as a literal, then maybe it does the
same. It still seems weird to me. I can accept that '\1' means x01,
but \10 seems to be expanded to \010 and then translated from octal
to get to x08. That's just strange. I'm sure it's documented
somewhere, but it's not easy to search for.
Oh, and this:
... is realy odd.
More information about the Python-list