This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: "\0" not listed as a valid escape in the lang reference
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: spiv, tim.peters
Priority: normal Keywords:

Created on 2005-01-24 02:09 by spiv, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg24024 - (view) Author: Andrew Bennetts (spiv) Date: 2005-01-24 02:09
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.
msg24025 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005-01-24 03:21
Logged In: YES 
user_id=31435

Look at the table of escapes again, especially the line with 
footnotes 3 and 5; that line documents the octal escapes, 
including all cases you've mentioned here.
msg24026 - (view) Author: Andrew Bennetts (spiv) Date: 2005-01-24 04:02
Logged In: YES 
user_id=50945

So it does.  I suck.  Thanks Tim!
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41479
2005-01-24 02:09:00spivcreate