[Python-3000] PEP 3137 plan of attack (original) (raw)

Thomas Lee tom at vector-seven.com
Tue Oct 9 17:54:00 CEST 2007


Guido van Rossum wrote:

- make == and != between PyBytes and PyUnicode return False instead of raising TypeError

Just thinking about it I'm pretty sure my initial patch is wrong - forgive my ignorance. To remove the ambiguity, is it fair to state the following?

bytes() == str() -> False instead of raising TypeError bytes() != str() -> True instead of raising TypeError

I initially read that as "return False whenever any comparison between bytes and unicode objects is attempted" ...

Assuming that PyUnicodeCompare is a three-way comparison (less, equal, more), it should raise a TypeError when one of the arguments is a PyString or PyBytes.

Cool. Should have that sorted out soon. As above:

str8() == str() -> False str8() != str() -> True

Correct?

Is it just me, or do string/bytes comparisons already work?

>>> s = str8('test') >>> b = b'test' >>> s == b True >>> b == s True >>> s != b False >>> b != s False Seems it's already so. Do they order properly too? (< <= > >=) Looks like it:

str8('a') > b'b' False str8('a') < b'b' True str8('a') <= b'b' True str8('a') >= b'b' False

Cheers, Tom



More information about the Python-3000 mailing list