Live data from Hacker News

New features you can't use unless you are in Python 3

asmeurer.com

41–50 of 264 posts

Re: New features you can't use unless you are in Python 3

#41

Quite a nice presentation! But I just wanted to point out that the title is a bit presumptuous. I don't refuse to upgrade to Python 3, it's that the default Python for most distributions is 2 (sometimes as far back as 2.6). If you want to write a user-space tool with Python you can either require additional dependency setup, bundle a full interpreter with your package, or just write Python 2.7/6 code that is forward…

Python 3 has been available on most dists for 5-10 years.

What I said was the default version of Python is old on most distributions.

For example, CentOS 6 ships with Python 2.6 out of the box. Even faster moving distros (like Ubuntu) are still trying to make Python 3 the default (although at least Ubuntu ships with both 2.7 and 3.4+ out of the box).

Re: New features you can't use unless you are in Python 3

#42

Quite a nice presentation! But I just wanted to point out that the title is a bit presumptuous. I don't refuse to upgrade to Python 3, it's that the default Python for most distributions is 2 (sometimes as far back as 2.6). If you want to write a user-space tool with Python you can either require additional dependency setup, bundle a full interpreter with your package, or just write Python 2.7/6 code that is forward…

Python 3 has been available on most dists for 5-10 years.

They are probably talking about "installed by default" vs available. Debian is still 2.x by default, and many of the Debian derivatives as well.

Not that the default install drives the whole ecosystem, but there are cases where targeting an interpreter you know will be there is helpful.

Re: New features you can't use unless you are in Python 3

#43
post #34

Earlier quoted context omitted.

Python 3 has been available on most dists for 5-10 years.

Furthermore, Python 2.x support will expire in 3 years. It's a lot less effort to install 3.x and use it now than plan, implement, and release a 3.x upgrade in 3 years.

They have been pushing support back for 2 for a long while.

But I agree with you:

> or just write Python 2.7/6 code that is forward compatible with Python 3...in which case I still can't use the new features of 3.

Although, personally, I think the best thing to do is write forward compatible Python 2 code (or at least as much as you can). At the very least write Python 2 code that lends itself well to using a migration tool like 2-to-3.

Re: New features you can't use unless you are in Python 3

#44
post #10
post #4

I'm impressed how much Python seems stuck on older versions. What went wrong?

Because after nearly 10 years this mediocre list is the best they can offer as consolidation for breaking your code, and for much of that time they didn't have everything it does now. If py3k shipped with something like https://gregoryszorc.com/blog/2017/03/13/from-__past__-impor... there probably would have been more uptake.

This piece barely scratches the surface, there's formatted string literals, type checking available, and compact ordered dicts by default in the latest. All awesomeness.

I'm glad they did the "mediocre" fixes as well, they lead to a lot fewer encoding (and other) bugs, which were a real problem on nontrivial programs.

Re: New features you can't use unless you are in Python 3

#45

Earlier quoted context omitted.

Python 3 has been available on most dists for 5-10 years.

What I said was the default version of Python is old on most distributions. For example, CentOS 6 ships with Python 2.6 out of the box. Even faster moving distros (like Ubuntu) are still trying to make Python 3 the default (although at least Ubuntu ships with both 2.7 and 3.4+ out of the box).

Centos 6 is 7 years old, if you are still using that it is unfortunately your problem. It's not hard to write "python3" on a modern dist.

Ubuntu has 3.5 and 3.6 is easily installable though not yet default 3.x.

Re: New features you can't use unless you are in Python 3

#46
post #31

Earlier quoted context omitted.

Python 3 has been available on most dists for 5-10 years.

macOS Sierra today tells me its python is 2.7

You should use homebrew to join the pythonistas club on Mac. Better yet, use https://github.com/asdf-vm/asdf/blob/master/README.md to get all the pythons, rubies, nodes, and golangs you want.

Ubuntu 18.04 LTS plans on Python 3-only, but Ubuntu has been shipping Python 3.x since 13.04 and 3.x is the default with 2.x available since 16.04 , so in terms of shipping Python 3 code, Ubuntu 12.04 LTS (the last LTS where you can't assume it has a python 3) EOL'd on April 28 2017. Assuming $WORK follows EOL depredations, you should be fine for Ubuntu.

Re: New features you can't use unless you are in Python 3

#48
post #4

I'm impressed how much Python seems stuck on older versions. What went wrong?

It was source-level incompatible with older code so it couldn't be used as a smooth transition like... almost any other language upgrade I've ever seen. Breaking code like this was a big mistake in my opinion - it resulted in many people sticking on the old version for code and library compatibility. There are still libraries which don't work on Python 3, though now fairly few of them. In addition to that, the unicod…

Well, even languages that bend themselves for backwards compatibility do introduce breaking changes, every now and then.

Re: New features you can't use unless you are in Python 3

#49
post #20

Does anyone use 2.x by choice? I've only seen it required as to not break legacy code.

This shouldn't be downvoted, it's a legit question. I hear some people really really prefer `print as statement`, but I've never seem them in real life.

Just from __past__ import print_statement

I really hope someone makes this work. I literally laughed and thought that it was a troll the first time I saw the future print import and that being used as a compelling reason that I should switch to Py3.

Re: New features you can't use unless you are in Python 3

#50

Open page. Nothing works. Enable their scripts. First slide shows but nothing works - except the link to the pdf version. Why not give a link to the pdf version in a element?

Yeah, it's good info in an unfortunate format by default.
Post reply on HN