[Python-Dev] Strings: '\012' -> '\n'
Tim Peters
tim.one@home.com
Mon, 15 Jan 2001 22:53:16 -0500
[?!ng]
> So... i'm submitting a patch that causes the three most common
> special whitespace characters, '\n', '\r', and '\t', to appear in
> their natural form rather than as octal escapes when strings are
> printed and repr()ed.
-1 on doing that when they're printed (although I probably misunderstand
what you mean there).
+1 for changing repr() as suggested.
-0 on generalizing to \a \b \f \v too (I've never used one of those in a
string literal in my life, so would be more baffled by seeing one come back
than I would the octal equivalent).
I would also be +1 on using hex escapes instead of octal (I grew up on 36-
and 60-bit machines, but that was the last time octal looked *natural*!).
Octal and hex escapes both consume 4 characters, so I can't imagine what
octal has going for it in the 21st century <wink>.
377-is-an-irritating-way-to-spell-ff-ly y'rs - tim
PS: Note that C doesn't define what numerical values \a etc have, just
that:
Each of these escape sequences shall produce a unique
implementation-defined value which can be stored in a single
char object. The external representations in a text file need
not be identical to the internal representations, and are
outside the scope of this International Standard.
The current method does have the advantage of extreme clarity.