News for hackers. Stuff that matters.
Re:Show HN: Shareable reasons to upgrade to Python 3 by Animats on Thursday August 10, 2017 @05:28PM (#14984477)
Unicode support and new style classes were in Python 2.7.

Type annotations that don't do anything are one of the worse ideas I've ever seen in a programming language. Optional type annotations that are checked and used for optimization would be fine. But what's gone in is useless. Also, the syntax, which puts some type information in comments, is lame.

Python 3 isn't bad at this point. The first few years of Python 3 really sucked. The syntax was less compatible, and particularly hard on those who used Unicode in Python 2.7, because u'abc' was prohibited. "2to3" didn't work very well. Many, many libraries were not converted. The newer libraries for Python 3 were buggy due to being underutilized. Python 3 before Python 3.3 was quite bad.

Most of that's been fixed. The "six" module was a big help in porting. Eventually, "u'abc" was allowed. Most of the libraries were ported and available and debugged on both 2.7 and 3.x. But it took many years, and gratuitous incompatibilities made it harder than necessary. It's fitting punishment for Von Rossum that he's forced to maintain the Python 2.7 system at his day job at Dropbox.

Re:Show HN: Shareable reasons to upgrade to Python 3 by canjobear on Thursday August 10, 2017 @06:34PM (#14984986)
> Unicode support and new style classes were in Python 2.7.

Unicode support is tremendously easier in Python 3. You don't have to deal with the confusing encode and decode stuff, and Python 3 strings have the right behavior in a lot of weird cases where Python 2.7 unicode objects do not.

Unicode support was my biggest reason for switching to Python 3, because I was dealing with natural language data with a lot of emojis and Python 2.7 was just an endless headache.

Re:Show HN: Shareable reasons to upgrade to Python 3 by mjevans on Thursday August 10, 2017 @06:55PM (#14985129)
I actually argue that it's worse. In Python 3 you are FORCED to deal with unicode encoding; Python 3 does not react well with legacy data that should just be handled as is (without making things worse or incompatible).

The alternative is to use a byte array without an encoding, which would be OK if Python 3 made coercion between the two easy (and had the concept of a 'validated' unicode string; operations known to keep a unicode string valid could leave that set, otherwise it would be 'not validated' but you wouldn't /need/ to care).

Re:Show HN: Shareable reasons to upgrade to Python 3 by zzleeper on Thursday August 10, 2017 @07:04PM (#14985176)
That prevents lots of mistakes. You only specify encodings while reading external data, and then everywhere else in your code you know you are dealing with strings and that's it (instead of your code working until a random Fóréígner trips it out)
Re:Show HN: Shareable reasons to upgrade to Python 3 by dbcurtis on Thursday August 10, 2017 @08:25PM (#14985638)
Well, I spend most of my time dealing with internet and serial protocols, and the strict demarcation between unicode strings and byte strings is what keeps me sane. Explicit encode/decode calls are a feature, IMHO.
Re:Show HN: Shareable reasons to upgrade to Python 3 by Avernar on Thursday August 10, 2017 @09:26PM (#14985939)
I wouldn't mind the strict demarcation if the internal format was UTF-8. Then a simple validate call on input would be all that was needed.
Re:Show HN: Shareable reasons to upgrade to Python 3 by joshuamorton on Thursday August 10, 2017 @05:42PM (#14984590)
> But what's gone in is useless. Also, the syntax, which puts some type information in comments, is lame.

This is only the case in python2. In python3(.6), I don't believe there is any type information that cannot be expressed only in comments.

Re:Show HN: Shareable reasons to upgrade to Python 3 by dragonwriter on Thursday August 10, 2017 @05:35PM (#14984543)
> Type annotations that don't do anything

As in any language, they “do something” in Python, to wit, enable static type checking.

Now, static type checking is provided by systems separate from the language implementation, but the still exists.

> Also, the syntax, which puts some type information in comments, is lame.

The comment-based component of the syntax is a compatibility feature for Py 2.x.

Re:Show HN: Shareable reasons to upgrade to Python 3 by Animats on Thursday August 10, 2017 @05:55PM (#14984695)
Now, static type checking is provided by systems separate from the language implementation, but the (sic) still exists.

That's almost a direct quote from the static typing proposal. No such checker existed at the time. There's a half-completed one, "mypy".[1] It's a bit different from Python 3.6 type annotation, though it tries to stay close.

Re:Show HN: Shareable reasons to upgrade to Python 3 by pddubs on Thursday August 10, 2017 @09:28PM (#14985951)
I think mypy can be considered the canonical type checker for python, Guido van Rossum works on that project. It uses python 3.6 type annotations fully as far as I know.