I strongly dislike Python 3

Chris Rebert clp2 at rebertia.com
Sat Jun 26 15:18:02 EDT 2010


On Sat, Jun 26, 2010 at 11:55 AM, Peter Kleiweg <p.c.j.kleiweg at rug.nl> wrote:
> Stephen Hansen schreef op de 26e dag van de zomermaand van het jaar 2010:
>> There were various serious problems with Python 2 which could not be fixed in
>> a backwards compatible way; we've been living with them for years and years
>> now, and it was decided that a single break to go back and correct them would
>> be preferable to keeping them forever.
>>
>> From the fact that "strings" in Python 2 ended up doing double-duty as both
>> octet sequences and arrays of character text, to yes the syntactical
>
> I have been using Python 3 for quite some time now, and this
> string thing in Python 3 has caused me more headaches than it
> ever did in Python 2.
<snip>
> Some basic text string functions seem to be working on byte
> string functions as well, but sometimes they don't, and there's
> no rhyme in why it does or doesn't.
>
>    >>> 'abcd'[0] == 'abcd'[:1]
>    True
>    >>> b'abcd'[0] == b'abcd'[:1]
>    False
>
> Why????

In the bytes example, the former expression gives an integer
corresponding the the value of the first byte, while the latter gives
a bytes object of length 1 (this reminds me of Ruby now that I think
about it).
The slicing behavior of bytes takes some getting used to, but there
aren't many good alternatives. Using chr() and ord() on bytes would
feel a bit weird, no?

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list