Changed my mind on comparing bytes to str.

This commit is contained in:
Guido van Rossum 2007-09-30 23:19:14 +00:00
parent ca6cf4fb2b
commit e2096897b5
1 changed files with 13 additions and 3 deletions

View File

@ -8,7 +8,7 @@ Type: Standards Track
Content-Type: text/x-rst
Created: 26-Sep-2007
Python-Version: 3.0
Post-History: 26-Sep-2007
Post-History: 26-Sep-2007, 30-Sep-2007
Introduction
============
@ -124,8 +124,18 @@ Comparisons
The bytes and buffer types are comparable with each other and
orderable, so that e.g. b'abc' == buffer(b'abc') < b'abd'.
Comparing either type to a str object raises an exception. This
turned out to be necessary to catch common mistakes.
Comparing either type to a str object for equality returns False
regardless of the contents of either operand. Ordering comparisons
with str raise TypeError. This is all conformant to the standard
rules for comparison and ordering between objects of incompatible
types.
(**Note:** in Python 3.0a1, comparing a bytes instance with a str
instance would raise TypeError, on the premise that this would catch
the occasional mistake quicker, especially in code ported from Python
2.x. However, a long discussion on the python-3000 list pointed out
so many problems with this that it is clearly a bad idea, to be rolled
back in 3.0a2 regardless of the fate of the rest of this PEP.)
Slicing
-------