Changed my mind on comparing bytes to str.
This commit is contained in:
parent
ca6cf4fb2b
commit
e2096897b5
16
pep-3137.txt
16
pep-3137.txt
|
@ -8,7 +8,7 @@ Type: Standards Track
|
||||||
Content-Type: text/x-rst
|
Content-Type: text/x-rst
|
||||||
Created: 26-Sep-2007
|
Created: 26-Sep-2007
|
||||||
Python-Version: 3.0
|
Python-Version: 3.0
|
||||||
Post-History: 26-Sep-2007
|
Post-History: 26-Sep-2007, 30-Sep-2007
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
============
|
============
|
||||||
|
@ -124,8 +124,18 @@ Comparisons
|
||||||
The bytes and buffer types are comparable with each other and
|
The bytes and buffer types are comparable with each other and
|
||||||
orderable, so that e.g. b'abc' == buffer(b'abc') < b'abd'.
|
orderable, so that e.g. b'abc' == buffer(b'abc') < b'abd'.
|
||||||
|
|
||||||
Comparing either type to a str object raises an exception. This
|
Comparing either type to a str object for equality returns False
|
||||||
turned out to be necessary to catch common mistakes.
|
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
|
Slicing
|
||||||
-------
|
-------
|
||||||
|
|
Loading…
Reference in New Issue