r/Python • • Nov 24 '16

The Case for Python 3

https://eev.ee/blog/2016/11/23/a-rebuttal-for-python-3/
575 Upvotes

349 comments sorted by

View all comments

10

u/billsil Nov 24 '16

Strings are difficult to use

They are, so you come up with a strategy to deal with them. Set your encoding at the boundary of your code and stop touching it.

Better error messages would be great, but I'd rather have horrific error messages as opposed to autoconverting madness. It's not possible to fix Python 2 code using just Python 2 if you only throw a unicode character through a function 1% of the time.

I like how easy Python 2 is, but strings are broken. It took me forever to figure out my data files are not in utf-8, but rather latin-1. They are not compatible.

Who really uses bytes anyways? Not beginners. They just set an encoding and they're done. You can just pretend your data is always in say latin-1 or utf-8 and it's probably going to work on an ASCII string. Bytes are a higher level feature. People just got used to using 'wb' because they didn't want stupid \r characters at the end of the line.

Too Many Formatting Options

Why would I ever use .format(...)? It's worse than %s and slower. There are now 2 methods in my book and 1 that I can use because I write Python 2/3 code.

5

u/LpSamuelm Nov 24 '16

Why would I ever use .format(...)? It's worse than %s and slower. There are now 2 methods in my book and 1 that I can use because I write Python 2/3 code.

That's interesting. I never use % formatting. It's a fairly gross overload of the modulus operator, and has weird syntax. str.format is explicit and clear, and if it's slower than % it's negligible.

→ More replies (9)