[Python-Dev] Python3 "complexity" (was RFC: PEP 460: Add bytes...)

Isaac Morland ijmorlan at uwaterloo.ca
Thu Jan 9 00:41:35 CET 2014


On Wed, 8 Jan 2014, Kristján Valur Jónsson wrote:

> Believe it or not, sometimes you really don't care about encodings.

> Sometimes you just want to parse text files.  Python 3 forces you to 
> think about abstract concepts like encodings when all you want is to 
> open that .txt file on the drive and extract some phone numbers and 
> merge in some email addresses.  What encoding does the file have?  Do I 
> care?  Must I care?

Mostly staying out of this, but I need to say something here.

If you don't know what encoding the file has, you don't know what bytes 
correspond to phone numbers.  So yes, you must care, or else you simply 
cannot write your code.

Of course, in practice, it's probably encoded in an ASCII-compatible 
encoding, so '0' encodes as the single byte 0x30.  Whether it's UTF-8, 
ISO-8859-1, or something else that is ASCII-compatible doesn't really 
matter.

So, as a practical matter, you can just use ISO-8859-1, even though in 
principal this is totally wrong.  Then ASCII is one byte per character as 
you expect, and all other bytes will round-trip unchanged.  Just don't do 
any non-trivial processing on non-ASCII characters.

I don't see how it could be made any simpler without going back to making 
it easy for people to pretend the issue doesn't exist at all and bringing 
back the attendant confusion and problems.

> I have lots of little utilities, to help me with day to day stuff like 
> this.  One fine morning I decided to start usnig Python 3 for the job. 
> Imagine my surprise when it turned out to make my job more complicated, 
> not easier.  Suddenly I had to start thining about stuff that hadn't 
> mattered at all, and still didn't really matter.  All it did was 
> complicate things for no benefit.
[....]
>
> All of this talk is positive, though.  The fact that these topics have 
> finally reached the halls of python-dev are indication that people out 
> there are _trying_ to move to 3.3 :)

Agreed.

Isaac Morland			CSCF Web Guru
DC 2619, x36650			WWW Software Specialist


More information about the Python-Dev mailing list