According to table in
http://docs.python.org/ref/strings.html, the list of
valid escape sequences in strings does not include \0.
It appears that the parser actually allows \n for
values of n in the range 0-7, but this is not documented.
Many people with exposure to C expect \0 to be valid
(and it does work, after all!). A quick grep on my
system finds many libraries use \0 in string literals,
including:
- Twisted
- HTMLgen
- PIL
- numarray
- Reportlab
- and of course the standard library: tarfile, gzip,
pystone, binhex, and others.
I suggest the documentation be updated to officially
support \0 as a valid escape. I don't care as much
about \1 through to \7... I was surprised they worked
(and then surprised that \8 and \9 didn't), and I think
they might as well be deprecated, but I don't care much
either way.
|