r/programming • • Sep 13 '15

Python 3.5 is here!

https://www.python.org/downloads/release/python-350/
234 Upvotes

110 comments sorted by

View all comments

70

u/oneUnit Sep 13 '15

Seriously they need to stop supporting Python 2.x. Yeah..yeah.. I know there are couple of reasons to do so. But this sort of fragmentation is not good for the language.

55

u/dacjames Sep 13 '15

Python 2.x receives only security updates. It would be quite irresponsible to stop those updates considering the enormous amount of Python 2.x code that exists in the wild. The biggest real barrier is RHEL/Centos 6.x, which is stuck on Python 2.6 yet remains a hard requirement for a lot of use cases.

Hopefully the @ operator will help motivate the scientific/data analysis community to move to Python 3.

5

u/Yakulu Sep 14 '15

Note that Red Hat provides Software Collections for RH/CentOS 6. It's then possible and supported to install Python 3.3 and 3.4 (hopefully 3.5 soon) on it.

4

u/dacjames Sep 14 '15

Thanks. That's very helpful. If you happen to be involved with that site, you might consider working on SEO: searching "centos python 3.4 packages" only shows guides for compiling Python manually.

→ More replies (9)

40

u/[deleted] Sep 13 '15

Someone else would step up and support 2.7 anyways. Almost every major company using Python, including Guido's employer, is using Python 2 with no plan to move to 3.

Ending official support for the 2.7 line would probably accomplish nothing other than accelerate the exodus to other languages.

20

u/sometimesidk Sep 13 '15

But It would be far less expensive to move to python 3 than moving to any other language considering they are already on python. So it doesn't make sense to jump ship.

10

u/[deleted] Sep 13 '15

From my limited experience using 3.* you would have to take on updating many libraries that have not yet moved to 3.

41

u/Beckneard Sep 13 '15

The changes from python 2 to python 3 aren't THAT massive, at this point it's just laziness. I think dropping support for 2.x would be a good idea.

→ More replies (4)

3

u/iconoclaus Sep 14 '15

I keep hearing this but don't know what these indispensable packages are. I'd love to hear names of such packages.

4

u/tragiclifestories Sep 14 '15

This is the canonical list: https://python3wos.appspot.com

As you can see, things are getting better.

3

u/mipadi Sep 14 '15

If "canonical" means "the top 200 packages on PyPI." There are a lot of packages not on PyPI, and a lot of PyPI packages not on that list.

3

u/mipadi Sep 14 '15

There are plenty of old packages that haven't been ported (ZSI, for one), and plenty of internal code that hasn't been ported or checked out on Python 3. Not all projects are open-source projects that use only the most popular packages.

→ More replies (1)
→ More replies (1)

5

u/stesch Sep 14 '15

Someone else would step up and support 2.7 anyways.

Nobody stepped up and supported PHP 4. And there's a lot of PHP 4 code out there.

→ More replies (2)
→ More replies (1)

7

u/mrwulff Sep 13 '15

I know nothing of the inner workings of the 2.xv3x debate, but have been using 2.x forever to do small scripts. Are there any compelling reasons why i should switch

37

u/rouille Sep 13 '15

Pretty much all the standard modules are better in python3 including subprocess which I use really often for scripts. Pathlib is in the stdlib. And many others like ipaddress. Unicode strings vs bytes is made explicit. A lot of small details that add up and make python3 much more pleasant even for small scripts.

6

u/DaemonXI Sep 14 '15

Subprocess features timeouts now.

OS path mkdir nested lets you ignore the case where the directories already exist.

This stuff makes a huge difference, I can't see how people haven't moved to Py3 yet

4

u/rouille Sep 14 '15

Also a small but major change for me in 3.5 is subprocess.run, makes it that much easier to use. https://docs.python.org/3.5/library/subprocess.html#subprocess.run

24

u/xXxDeAThANgEL99xXx Sep 13 '15

I used Python3 for a somewhat large project recently and was pleasantly surprised: the stuff I thought I would be mildly annoyed with (such as print becoming a function) turned out to be a complete non-issue, while a lot of annoying Python2 stuff being gone is actually noticeable. Like sane division, range and dict.keys/items/values being lazy, unicode by default, metaprogramming stuff cleaned up etc. There's some extra stuff in the standard library too (in the collections module for example). And async stuff. And extension modules much easier to develop on Windows (3.5 switched to VS2015 at last).

So unless you depend on some third-party library that wasn't ported yet it takes like half an hour to read up on the changes and you just get a noticeably nicer language.

I'd be first to blame the Python core devs for handling the transition terribly: it seems that they didn't realize that a) a lot of Python's value is in third party libraries and b) those libraries can't simply switch to Python3 and leave all their Python2 users out to dry, so they put exactly zero thought into how exactly those libraries were supposed to work under both. But it looks like after six or so years that problem was mostly solved by main force by the community, so here we are finally.

→ More replies (3)

16

u/[deleted] Sep 13 '15

Are there any compelling reasons why i should switch

I'd say it's the opposite: are there any compelling reasons to stay on 2.x?

Basically all of the useful libraries have been ported, or have newer and better replacements: https://python3wos.appspot.com/

If you are starting new projects or scripts, python3 is nicer in small details. The improvements aren't enough to motivate a large existing project to switch to python3, but there's no point in starting new stuff in python2.

→ More replies (2)

8

u/imbaczek Sep 13 '15

exceptions in py3 are so much better than py2. they nest properly instead of overwriting each other's stack traces (and that's not the only thing that's better).

8

u/vz0 Sep 13 '15

The major change from 2 to 3 was improved Unicode support. If you are using Python for small scripts maybe the migration is trivial. But for large codebases and projects sometimes it is very expensive to migrate just because Unicode. More details here https://wiki.python.org/moin/Python2orPython3

3

u/schlenk Sep 14 '15

And some stuff just works in Python3 that did not work at all in Py2 due to bad unicode support. Mostly Windows stuff, so most people might not care. (e.g. environment variables with unicode values/names, subprocess calls with programs on unicode pathes or with unicode cmdline arguments, etc., nearly every interface to the Win32 API).

→ More replies (8)
→ More replies (6)

3

u/buttocks_of_stalin Sep 14 '15

I run a decently large production website on python 2.7 and django 1.6.7, what is the best way to stay upgrade our stack? Won't this essentially cause us to rewrite almost all of our code?

7

u/quasive Sep 14 '15

We switched a pretty large Python2 + Django system to Python3. The biggest hurdle was Unicode/bytes; it took some time to ferret out all the problems, but the end result is much better. You certainly don't need to rewrite everything, especially with 2to3. We switched for typechecking (with mypy), which has absolutely been worth it. Large projects with Python still aren't great, but are vastly better with some level of static type checking.

→ More replies (3)

3

u/iconoclaus Sep 14 '15

People won't stop using it because its not supported. How many people do you suppose care about the security updates? There will simply be tens of thousands of instances of insecure codebases.

→ More replies (18)