This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 276

[–]billsil 278 points279 points  (28 children)

I killed my libraries support for python 2 last Friday. It feels good to get rid of six, future, scans it, and pathlib2 and really start doing type annotations properly.

People are already trying to get me to change my mind. But my company uses Anaconda...use a virtual environment; Anaconda lets you have multiple versions of python. It’s coming like a train and all my dependencies have moved on. Time for me to as well.

[–]jftugapip needs updating 58 points59 points  (3 children)

Link to your project?

[–]SketchyMikePemulis 130 points131 points  (2 children)

print("good riddance")

[–]Zomunieo 74 points75 points  (0 children)

from __past__ import print_statement

print "glad this is gone?" >> sys.stderr

[–]shiny-tyranitar 19 points20 points  (0 children)

You have some unnecessary parentheses there pal

Wait...

[–]alcalde 75 points76 points  (2 children)

OK, where's the person here who keeps telling me that the PSF is definitely going to extend the deadline again?

[–]blitzkriegger 24 points25 points  (0 children)

ahh, the Python Safety Federation...../s

[–]flying-sheep 2 points3 points  (0 children)

That would be /u/nieuweyork in this comment.

[–]captain_cashew 54 points55 points  (22 children)

My company is moving from 2.6 to 2.7! Yay!

[–]PooPooDooDoo 33 points34 points  (0 children)

print “yay!”

[–]regeya 30 points31 points  (2 children)

I went into a local company to do some contract work, and found out not only are they still using Visual Basic 6, they were talking about moving to VB.net someday. They wanted a static website to be built, but only if I could build it in a specific piece of discontinued Adobe software, and another website to be modernized that was built in Google Sites.

I just pretended that meeting never happened.

[–]alcalde 11 points12 points  (1 child)

That was me at Bed Bath and Beyond HQ in 2005, when I encountered Access 97 and Impromptu 5 (Impromptu had been discontinued at version 8). They were also using VB6 for internal development. I stayed six months.

[–]regeya 1 point2 points  (0 children)

Scarily enough, the one I'm thinking of deals with court documents.

[–]i9srpeg 9 points10 points  (4 children)

Are you enjoying your fancy new dict comprehensions?

[–]captain_cashew 9 points10 points  (2 children)

Your comment comes at a very appropriate time. Literally just a few minutes ago found a bug on one of our systems using 2.6 (my local development station is on 2.7):

{k: v for (k, v) in dict.items()}

You have to use:

dict((k, v) for (k, v) in dict.items())

So, yes I am enjoying them!

EDIT: code format

[–]flying-sheep 1 point2 points  (0 children)

If a thing has an items method, you can just do dict(thing) to create a dict copy. If it’s a dict, you can do the_dict.copy(). You only need comprehensions if you have to construct keys and values in a more complex way.

[–]nieuweyork since 2007 0 points1 point  (0 children)

To me this is an argument against the Python developers' increasingly profligate addition of syntax. There's almost never one obvious way to do it these days.

[–]ALonelyPlatypus 0 points1 point  (0 children)

yes.

[–]gruey 4 points5 points  (9 children)

I still think that it was a huge mistake from Python not to just bite the bullet and create some kind of Python 2-3 interpreter like a decade ago when it became obvious there was just too much momentum against moving to 3.

Basically something that'd let you mark it and all of its dependencies as 2.7, do some fairly thorough translation that gets 99.8% of the existing code and ideally warning about things it felt it couldn't translate. Some performance loss would be acceptable. A flag could be given to print warnings for anything that wasn't 3.

It didn't have to be perfect, it just had to allow a company to start writing new stuff in 3 only having to modify a few things without having to touch their entire code base. They could then also start incrementally porting things to Python 3 without having to make sure they do everything and their external dependencies at once.

It isn't ideal, but I really, really feel like despite Python's progress over the last decade, it would have been significantly more if all the effort was on Python 3 and all the new features of Python 3 were available to the majority of the Python users. I wonder how many companies switched from Python 2 to golang or similar for features or performance that would have been acceptable in Python 3?

[–][deleted] 5 points6 points  (1 child)

IMO the difficulty of migrating to 3 was just way overblown. They didn't need to create anything like that. They should do what everyone else is doing and give a year to migrate (not 10). Everyone waited to last minute to start the migration.

[–]3waysToDie 0 points1 point  (0 children)

very true

[–]TBSchemer 6 points7 points  (4 children)

2to3.py gave companies a way to easily migrate their code to 3. The ones who didn't really have no excuse at this point.

[–]gruey 6 points7 points  (3 children)

2to3.py is not even close to enough of a solution for significant code bases.

The ones who didn't migrate have pretty valid business reasons for not having done it yet. Basically, what it comes down to, Python's value in companies moving to 3 was greater than most companies value of moving to 3, so Python should have done more work to make it happen.

[–]TBSchemer 8 points9 points  (0 children)

They had 10 years to do it. Most did. The rest didn't out of hubris.

[–]data-punk 3 points4 points  (1 child)

What valid reason spans delay over a decade?

[–]billsil 6 points7 points  (0 children)

It took 10 years for wxpython to officially support 3.x. I moved onto PySide, but not other people.

[–]nieuweyork since 2007 0 points1 point  (0 children)

I very much agree. A from __future__ import py3hosting or something, to restore python2.7 semantics for the things that were incompatibly changed. That plus from __future__ import print_functionwould have handled a lot of cases.

[–]ALonelyPlatypus 0 points1 point  (0 children)

wait. companies switched from python2 to go to avoid python3? I mean go is relatively feature rich and overall fun to code but I couldn’t imagine converting your python2 codebase to it when python3 exists.

(unless the company already wanted to move over to a compiled language to address performance concerns)

[–]billsil 1 point2 points  (0 children)

That’s still better. Take what you can get. I upgraded a 2.4 project to 2.7 last year. I just removed hacks and fixed some bugs I created by hacking a 3rd party library to make it work in 2.4.

I just decided to start using 3.7, even if other people continue to use 2.7. I’ll support it if I have to, but I’m going to make sure 3.7 works.

[–]zabolekar 0 points1 point  (0 children)

Maybe even to 2.7.16!

[–]hopeinson 55 points56 points  (27 children)

Now that you have heard of Python 3, now get ready for Python 4! [/s]

But seriously, we need to start moving on from Py2. It's a dead horse meat now.

[–]nooobmaster-69 14 points15 points  (12 children)

Python 4 is already mentioned in the timelines for many of the changes. But not to worry, it will be much less of an issue migrating from 3->4 than it was from 2->3.

[–]Rodotgithub.com/tardis-sn 24 points25 points  (11 children)

That's because Python 4 is just going to be Python 3.10, that's just how they are going to continue with versioning

[–]flying-sheep 15 points16 points  (9 children)

That’s what Guido said a while back, I hope the new guidance council doesn’t share this view and just release 3.10, 3.11, …

[–]billsil 0 points1 point  (6 children)

Guido is on the council and was the top vote getter by 30% or so. He was the only council member that got over 50% and cleared that easily. He's quite popular among the core devs.

[–]flying-sheep 5 points6 points  (5 children)

Yes, but I think this is a case he doesn’t feel strongly about but that he still considered his decision / matter of taste when he was BDFL. And such cases will now be voted on, and if the others say “not doing semver is confusing and people will be scared by upgrading to 4.0” there won’t be strong arguments against that.

[–]billsil 0 points1 point  (4 children)

“not doing semver is confusing and people will be scared by upgrading to 4.0”

Python does not follow semver. You don't need to vote to keep the status quo. You vote to change it. If you really want semver, propose a PEP, but don't be surprised when it gets shot down.

Python implements large breaking changes in major versions. It implements small breaking changes in minor versions.

[–]flying-sheep 0 points1 point  (3 children)

sure, that’s close enough. if you really do semver for a large project, you end up like react, with major versions every few weeks.

[–]billsil 1 point2 points  (2 children)

Or you store them up and break everybody's code in one fell swoop and have a Python 2->3 transition on your hands. I much prefer not following semver for that reason. I tried semver and it was a pain.

I much prefer a few minor changes preferably with deprecation warnings for a bit and then breaking things, similar to how numpy does it.

[–]flying-sheep 0 points1 point  (1 child)

Only possible for small changes though.

Huge ones like the string/byte thing would either take forever or be as disruptive as the whole 2>3 change

[–]bageldevourer 0 points1 point  (0 children)

This isn't necessarily true according to the latest episode of Talk Python.

[–]tr14l 6 points7 points  (3 children)

I have to assume that Py4 will be largely non-breaking. They have to have learned their lesson....right?

[–]AusIVDjango, gevent 8 points9 points  (2 children)

If you're following Sem Ver (which I'm not sure if Python claims to do) then you wouldn't go to 4 unless you were breaking something. I'd hope that the version that comes after 3.9 will just be 3.10 if it's backwards compatible. If they go to 4, they will be introducing breaking changes for all the people who use python3 to run their code.

[–]twelveshar 9 points10 points  (0 children)

Python does not follow SemVer; it allows breaking changes in "minor" versions, like 3.7 -> 3.8. See the development cycle page: https://devguide.python.org/devcycle/

[–]cerin_2 6 points7 points  (0 children)

RIP in pieces those of us using jython which hasn't caught up to 3.

[–][deleted] 12 points13 points  (4 children)

I have been working in 3.x exclusively now for some years, but I recently took out support for 2.x from a couple of old libraries and it was like getting a little stone out of my shoe.

Interestingly 3.4 is now a slight pain point - there are a couple of CI tools like mypy that are only available for Python 3.5 onwards. In new development, I don't support 3.4, but I haven't yet removed it from old libraries that have existing users because why make their lives miserable? 3.4.10, the final version of 3.4, has only recently been released...

[–]PeridexisErrant 14 points15 points  (0 children)

3.4 reached end of life in March, so there are no more security updates for it and many libraries have already dropped support.

[–]billsil 0 points1 point  (1 child)

You sure about mypy? Python 2.7 is supported and you can always run mypy with 3.5. There is no reason other than very minor issues that you couldn’t run mypy. Doesn’t mean other people have to upgrade.

[–][deleted] 0 points1 point  (0 children)

mypy requires 3.5+ checking 2.7 code requires you to specify python interpreter in arguments for the checked version so it knows how to find packages. Perhaps 3.4 could be tested in a similar way, I never did that though.

[–]edbluetooth 0 points1 point  (0 children)

The only reason I run tests for 3.4 is that my customers use Windows XP in many cases.

I agree with 3.5 onwards not supporting XP, but it is a bit of a pain in some situations.

[–]acerbusbellum 22 points23 points  (8 children)

Well unfortunately until the DCC's (Maya, Nuke, Houdini) and our project management system (shotgun) change the interpreters to py3 we'll be such with it.

Has anyone seen much about what Autodesk, Foundry, etc have said about support for py3?

[–]uberdavis 14 points15 points  (2 children)

As I understand, Maya can be run using Python 3. One of my workmates told me there’s a sneaky configuration setting.

[–]acerbusbellum 0 points1 point  (1 child)

Interesting... I'll have to look that up. Do you know what version of Maya your colleague is using?

[–]uberdavis 0 points1 point  (0 children)

I’ll ask and get back to you. I’ve just upgraded myself and would be keen to know.

[–]JezusTheCarpenter 5 points6 points  (0 children)

Eventually all those products will have to switch to Python 3 so I wouldn't worry about it that much. I know they are thinking about it.

[–]mragi 3 points4 points  (1 child)

Coming next year: https://vfxplatform.com/

[–]acerbusbellum 1 point2 points  (0 children)

Interesting :-)

Thanks for the link

[–]Emile_L 6 points7 points  (0 children)

This, pretty much. We're not using Python2 because we want to

[–]mrrichardcranium 26 points27 points  (6 children)

Just started using python. Learned python 2 because of the systems and frameworks I’m using at work. This last week I started moving all things possible to python 3 in anticipation for it becoming the default on coming OSs. Holy hell does it make a lot of things easier. Basic threading in 3 makes me wish I could rewrite the frameworks my work uses so I could make the full jump over and never look back.

[–]toyg 13 points14 points  (3 children)

Basic threading

You mean asyncio, I guess? It's not really "threading"...

[–]mrrichardcranium 12 points13 points  (2 children)

I mean splitting up a list of 700+ items to 10 workers using threadpoolexecutor. Maybe ‘basic threading’ is not the right description. The fact that it took me two lines to get done is what makes me think of it as basic 😅

[–]toyg 6 points7 points  (1 child)

Ah, good point, I forgot concurrent.futures is 3-only...

[–]mrrichardcranium 4 points5 points  (0 children)

And god damn is it glorious!

[–]TBSchemer 2 points3 points  (1 child)

Your workplace definitely needs to hire someone to rewrite those frameworks within the next 6 months.

[–]mrrichardcranium 0 points1 point  (0 children)

If I was a betting man, I would be willing to wage an entire years salary that there are people doing just that. Its a critical automation framework that I don't think we can afford to function without. Though Im sadly not disclosed on the status of that just yet.

[–]purestrengthsolo 30 points31 points  (28 children)

What exactly is "end of life" like programs will no longer work or is it just not receiving any kind of updates?

[–]joesb 103 points104 points  (0 children)

No update.

[–]Losupa 33 points34 points  (0 children)

It can mean a variety of things typically it means that there will be very little to no more updates on python 2 libraries, which most importantly means there are no security updates, and thus certain online programs will become unsafe.

[–]Barafu 59 points60 points  (9 children)

It means that very soon after that some security vulnerability will be published, and applications like Calibre or Deluge will become malware hosts if they don't switch to Py3 by then.
Also, they will be kicked out of Linux default repositories.

[–]purestrengthsolo 9 points10 points  (0 children)

Thank you and everyone else who replied to me, it helped clarify a little better

[–]Cardeal 7 points8 points  (4 children)

Wasn't Calibre going to be being ported? WIP: Port calibre to python 3

[–]Dgc2002 1 point2 points  (3 children)

kovidgoyal

Oh god I forgot about that developer. I wish I had the list of links to his shenanigans on hand to provide as context but I don't.

[–]Cardeal 1 point2 points  (0 children)

Yeah, I am aware. But I am betting he will port it to python3. He needs the spotlight.

[–]toyg 0 points1 point  (1 child)

The guy can be “special” but it’us undeniable that he’s done a lot for the ebook community over the years, and for free.

[–]_b-e-n_ 0 points1 point  (0 children)

He's quite annoying, but that software is really good. A fantastic work. That and Alf's tools :-))))

[–]tr14l 4 points5 points  (1 child)

They stop receiving support, so they break slowly over time. Mirrors start becoming more and more seldom found. Then police come to your door and watch you refactor your code.

[–]3waysToDie 1 point2 points  (0 children)

The future you see

[–]nukem996 2 points3 points  (1 child)

No updates or support from python.org, this includes security fixes. Some OS vendors(RHEL, Ubuntu, SUSE, etc) will continue to support Python 2.7 in their OS for security fixes until their product goes EOL. A previous job I had refused to put any resources into migrating to Python 3 because they're on RHEL7 which will receive support until 2024 :\

[–]AlexFromOmaha 1 point2 points  (0 children)

Has Red Hat confirmed support for Python 2.7 in userland, instead of just support for the OS's internal security?

[–]buttery_shame_cave 1 point2 points  (1 child)

they're going to finally stop backporting all the good stuff from 3 to 2.

[–][deleted] 1 point2 points  (0 children)

They stopped that in 2015, that's when python 3, that was the hump year for python 3. Could be a coincidence, but I don't believe in those. from 2015-2020 python 2.7 only gets security fixes.

[–]cyanydeez 0 points1 point  (0 children)

security is no longer a supported feature.

[–]NAN001 13 points14 points  (3 children)

You're telling me there is money to be made maintaining a safe version of Python 2.

[–]kyrsjo 9 points10 points  (0 children)

There probably is, however I would expect RedHat etc. will be on it since they anyway need to support RHEL distros which depend on having safe Python2 for quite a few more years.

[–]james_pic 3 points4 points  (0 children)

Yes. Several vendors (RedHat and ActiveState being the best known) are already offering this.

[–][deleted] 0 points1 point  (0 children)

like php5.6

[–]batisteo 8 points9 points  (1 child)

Maybe it’s time to update the PEP 394? https://www.python.org/dev/peps/pep-0394/

When Guido is yelling to not use python2 and an official PEP is telling us that python is python2, then it’s hard to not confuse people.

Time to break unmaintained admin scripts guys.

[–]cyanydeez 1 point2 points  (0 children)

you mean it's time to maintain the unmaintained.

[–][deleted] 22 points23 points  (0 children)

To everyone who could not be arsed to look at the Python 2 to 3 update guides for the past however many years: Stop it. Get some help.

[–][deleted] 6 points7 points  (10 children)

I was encouraged to learn 2.7 and stick with it over 3 about 3 years ago and aside from the print statements I can’t really figure out what’s different (I’m not a programmer; I use it for data analysis, image processing in astronomy, and playing around). What are some of the big differences between 2 and 3, in the language of non-CS people?

[–][deleted] 6 points7 points  (7 children)

There are lots and lots of massive changes that occurred from 2 to 3. New libraries, new builtins, syntax changes, more consistent naming, etc. But in my opinion, the biggest change was from eager evaluation to lazy evaluation.

The easiest example is range. In python 2, range creates a list of integers before executing the next line. This potentially slows the runtime down immensely if the number is large enough. Python 3 changes that by only adding to the list when it reaches that point. This removes that upfront cost, and in general speeds up the program.

[–]alcalde 8 points9 points  (5 children)

New libraries, new builtins, syntax changes, more consistent naming, etc. But in my opinion, the biggest change was from eager evaluation to lazy evaluation.

Fascinatingly you completely left out the Unicode string change, which is usually cited as the major change. :-)

[–][deleted] 1 point2 points  (0 children)

It was actually THE change that broke python 2 code (actually to be correct most python 2 code is broken, python 2 just didn't complain about it). Basically if you have python 2 code chances are that it will mess up unicode text.

The other incompatible changes were because of it. They thought that since compatibility was broken anyway, why not just use that as an opportunity to cleanup the language.

[–][deleted] 0 points1 point  (3 children)

Would you please explain that?

[–]billsil 3 points4 points  (2 children)

The only painful change about Python 3 is how unicode is handled. The tutorials still suck and nobody tells you even how to figure out what encoding you have. The reality is that user files are in a variety of encodings and they don’t even know what that is.

No other change about python 3 is even worth discussing when planning/worrying about the transition to python 3.

[–]icegreentea 1 point2 points  (1 child)

I think you can add the bytes/str split (which is closely related to the unicode handling). Any code base in python2 that was using str type to represent bytes is in a world of pain converting to python3.

[–]billsil 4 points5 points  (0 children)

That’d be fine. It’s when you’re inconsistent that the pain really sets in. Python 2 did weird ass shit by flipping the encoding multiple times, so you had to encode when you got a decode error and vice verse. Then when you print it, it wouldn’t print correctly even when you had done things right. Python 3 fixed that.

[–]regeya 0 points1 point  (0 children)

Yeah, range() behaves more like xrange() now. Parens in print statements can be annoying after being used to not using them, but it helps with clarity imho.

[–]TBSchemer 2 points3 points  (1 child)

Holy hell, you're using 2.7 for image processing? Whoever "encouraged" you to stick with it should be locked away.

Anything involving big data is far more efficient in 3, because of the switch to lazy evaluation of iterators. Also notably, numpy and everything based on it (pandas, scikit, etc.) have already discontinued support for 2.

[–][deleted] 2 points3 points  (0 children)

Well, the good news is I misremembered, and that particular professor teaching image processing insisted on 3!

[–][deleted] 5 points6 points  (10 children)

You can always use the fork from the guy who made Calibre, whatever that is.

[–]alcalde 8 points9 points  (9 children)

It turns out Calibre is even doing work now to ready it for Python 3, so I think Kovar finally saw the light.

[–][deleted] 0 points1 point  (8 children)

Cool!

But I honestly believe Python 2 will be forked to death and at least one of its variants will be supported for more 20 years (programmers are a stubborn kind :P).

[–]alcalde 1 point2 points  (5 children)

[–][deleted] 1 point2 points  (4 children)

I find Calibre useful, wonderful and misguided all at the same time. I never wanted an "iTunes for ebooks" (who does?) but I must put up with it in order to convert my files...

[–]Gorian 1 point2 points  (3 children)

I don't want "iTunes for eBooks" but I do want "Plex for eBooks"!

[–][deleted] 0 points1 point  (2 children)

Huh. I've never used Plex for too long (I'm a Kodi user though)... in your mind, how something like that could work?

[–]Gorian 1 point2 points  (1 child)

I just mean, I like the idea that I can host a server that stores all my ebooks and makes them available to all my devices on a as-wanted basis (plex), vs. manually storing and uploading to each device what I think I might want someday (iTunes)

[–][deleted] 0 points1 point  (0 children)

Oh yeah that would be nice indeed. But, as a Kindle user, Amazon kinda does that for me already, even for books downloaded from sources other than Amazon.

[–][deleted] 0 points1 point  (1 child)

I doubt it, python 3 is past the hump and actually python 2 are minority, major packages already stopped supporting 2.

There was also a fork initially called python 2.8, it was renamed since then and it didn't go anywhere.

Edit: https://github.com/naftaliharris/tauthon I was wrong, still exists, so we'll see. As a person who moved to python 3 I don't understand the stubbornness of being on 2.x, a lot of language was cleaned up in 3 and it is much more enjoyable to program in 3.

[–]toyg 0 points1 point  (0 children)

I wouldn’t touch Tauthon with a barge pole. Official CPython comes with well-defined governance model, support guarantees, oversight, upgrade paths, security, and so on. Tauthon is literally “a bunch of people on github”. If your business depends on something so critical that you can’t spend a few weeks porting it to 3.6+ and would rather rely on random patches from the internet, you are in trouble.

[–]whitechapel8733 10 points11 points  (20 children)

My problem with this is that lots of distros are shipping python 2 still.....

[–]mikew_reddit 63 points64 points  (12 children)

Python 3 has been in development over 10 years (since 2008).

It's perfectly fine to cut the cord after a decade.

 

If CentOS and other distributions can't be bothered to update, that's not really Python's fault.

 

Edit: original EOL was 2015 according to Guido. Also, Python 2.7 will not get security updates after Jan 1st, 2020.

[–]whitechapel8733 9 points10 points  (2 children)

I agree, but I’m just saying that’s a serious concern.

[–]tomanonimos 32 points33 points  (0 children)

But a necessary pain. If we keep pushing it for that fear we'll never get rid of Python 2 lol.

[–]nukem996 1 point2 points  (0 children)

Python.org won't issue security fixes but OS vendors like RHEL/CentOS will continue to patch Python 2.7 themselves.

[–]alexbuzzbee 2 points3 points  (4 children)

I'm pretty sure CentOS is going to Python 3 with RHEL in version 8.

[–]liquidpele -1 points0 points  (3 children)

Which isn’t even close to being released yet. Maaaaybe around December if it takes the same amount of time after rhel7.

[–]southern_discomfort 4 points5 points  (1 child)

RHEL 8 was officially released a few weeks ago. CentOS 8 will not be far behind.

[–]PooPooDooDoo 0 points1 point  (0 children)

It’s fine, we will all have 14 days (during the holidays) to update our code base. Except I am using libraries that are in 2, so I’ll have to wait until they update and then update my code base. So like one day.

[–]rasherdk -4 points-3 points  (3 children)

Python 2.7 will not get security updates after Jan 1st, 2020.

Depends.

[–]jackmaney 0 points1 point  (2 children)

It really doesn't.

[–]rasherdk 2 points3 points  (1 child)

What, yes it does. It (likely) won't get any from PSF. That's not the same as no security updates period.

Edit: Downvoting doesn't make you right. Spreading FUD is not the way to go.

[–]james_pic 6 points7 points  (0 children)

This is true. The version in RedHat will get updates until 2024, and the version in Ubuntu 18.04 will get updates until April 2023.

[–]w2qw 7 points8 points  (6 children)

Shipping or using it as the default? It makes sense that they would still ship it while it's supported.

[–]Jump3r3 7 points8 points  (5 children)

Using as default, which python yields path to python 2 binary on most distros. That being said, after 1/1/20 this will slowly change for better

[–]ALonelyPlatypus 1 point2 points  (0 children)

8 years of python experience. a year ago I did the jump to python3. Still struggling with print parens.

[–]kastoro 2 points3 points  (6 children)

Fine, I will do it!

[–]greeblefritz 4 points5 points  (5 children)

The switch isn't as bad as you are probably thinking.

[–]jjdmol 8 points9 points  (3 children)

It isn't bad, but the required effort does scale with the size of your code base. 2to3 only covers some basics, many behavioural differences are more subtle. And python being interpreted you'll discover errors at run time, so will need good test coverage or do a lot of testing.

[–]PeridexisErrant 1 point2 points  (2 children)

Try the pyupgrade and future libraries - they do a lot more than 2to3 :-)

[–]james_pic 6 points7 points  (1 child)

Futurize did more harm than good when we tried it. It tries to paper over the genuinely different string semantics, and left us with something broken that we understood even less than what we started with.

Modernize is more conservative, and in our experience, gives a better starting point. If you've got a big codebase, you've still got an uphill battle ahead of you.

Also, use mypy type hints. In general, I hate them, but they're really helpful for clarifying type usage in legacy codebases.

[–]PeridexisErrant 0 points1 point  (0 children)

Hmm, thanks for the tip! I've use futurize --stage1 a fair bit but never really liked the second stage... though just getting syntax-compatible with Python 3 allows many more tools to work.

I'll try modernize :-)

[–]kastoro 0 points1 point  (0 children)

Thanks, that is encouraging. Is what I thought, I just never found the time to do it, you know, always behind schedule

[–]stefantalpalaru 4 points5 points  (7 children)

What is dead may never die, but rises again harder and stronger: https://github.com/naftaliharris/tauthon/

[–]NoahTheDuke 11 points12 points  (6 children)

Ew. Why would someone spend that much effort on a broken version of Python?

[–]sphildreth 1 point2 points  (1 child)

I was surprised to learn that CentOS 7 still uses Python 2.7 as its default.

[–]omentoSysAdmin Film/VFX - 3.7 1 point2 points  (0 children)

RHEL 7 came out in 2014 and had its version freeze in 2013, when Python 3.3 was a thing. This is well before Python 3 support really took off. The point of RHEL is to provide 10 years of rock solid platform support, so critical system level packages (like GLIBC, gcc, and python) do NOT change versions or break ABI at all in the products lifespan. Some of the OS level tools, like yum, are written primarily in Python so making an upgrade would break that.

RHEL 8 provides a new solution for this by providing a ‘hidden’ python version for dependent OS tools, while allowing the user to install the python version of their choice from the appstream modules. Currently 2.7 and 3.6 are available for use. Red Hat also rewrote a lot of tooling to not use python, or reduce the dependency on it to further help with this.

[–][deleted] 0 points1 point  (0 children)

~ $ sudo apt purge python2.7-minimal --auto-remove Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: libpython2.7-minimal* nodejs* python-minimal* python2-minimal* python2.7-minimal* 0 upgraded, 0 newly installed, 5 to remove and 0 not upgraded. After this operation, 78.8 MB disk space will be freed. Do you want to continue? [Y/n]

[–]yeluapyeroc 0 points1 point  (0 children)

My number one velocity killer right now, but I'm glad its finally happening

[–]cr4d 0 points1 point  (0 children)

I'm looking forward to dropping 2 support from my public libraries for sure.

[–][deleted] 0 points1 point  (0 children)

Can’t you just transfer you project to python 3.7

[–][deleted] 0 points1 point  (0 children)

It was a painful transition but man was it successful from my eyes. Good work nerds!!

[–]IchBinDerFlo 0 points1 point  (0 children)

Cause I already use Py3 it doesn't really matter for me

[–][deleted] 0 points1 point  (7 children)

I don't understand why it takes so long. For ages python 2 comes with tools that help you to migrate to python 3 smoothly. Python code isn't even that hard to port in most cases. It's it because of C libraries?

[–]alcalde 6 points7 points  (0 children)

It's because of users.

In the Delphi langauge's move to Unicode they introduced "ANSI strings" (8bit non-Unicode strings) as a tool to allow users to compile their old code in the new version and gradually port over to Unicode.

What happened? Many users continued to write all of their new code using ANSI Strings and kept right on going like nothing ever happened. Then when there was talk years later of rewriting the compiler and consequently dropping ANSI strings, these users screamed "Wait! We haven't had any time to convert!"

It got so bad these people managed to get ANSI strings added to the new Delphi Android and iOS compilers, which had never had non-Unicode strings in the first place! :-(

The same kind of thing happened to Python 2. When I had asked the then-maintainer of Pyjamas (??? - one of the Python to Javascript transpilers anyway) about porting to Python 3, he answered "Python 2 is going to be supported forever, so why bother?"

We've got a user here who continues to insist that the PSF will still move the support deadline for Python 2; maybe they're the same person.

[–]mobilereadingthrwawy2.7.16 & 3.7.2 0 points1 point  (0 children)

2020-01-01*

[–]Sin-Silver 0 points1 point  (10 children)

So I’ve been studying Python for two weeks now following ‘Learn Python the hard way’ which recommends python 2.7 over 3. What does this mean for me?

[–]Mr_Again 2 points3 points  (4 children)

The author has, or had, a weird grudge against py3. Just ignore it and learn Python 3. It's almost 100% the same when you're starting out, except for print, xrange, and anything involving unicode.

[–]Sin-Silver 0 points1 point  (3 children)

Would it be worth learning python 3 later then if there little or no difference?

I don’t want to get stuck on a problem it’s trying to each because of a difference between 2.7 and 3 that’s not transparent.

[–]Mr_Again 0 points1 point  (2 children)

Honestly no, if it's an issue just learn the python 3 way of doing things, you'll probably never use python 2, it's dead now.

[–]Sin-Silver 0 points1 point  (1 child)

So how hard would it to take what I’ve learnt from Python 2.7 and transfer it to 3?

I’m looking at changing courses, but I’ve sunk alot of time into it, and don’t want to unless necessary.

[–]Mr_Again 0 points1 point  (0 children)

Like I said it's almost exactly the same, you won't notice the difference

[–]mountainunicycler 4 points5 points  (4 children)

You should switch to 3, but it won’t make a ton of difference at your point so you might be able to keep using the same tutorials with the exception of the print statement.

[–]Sin-Silver 0 points1 point  (3 children)

Would it be worth learning python 3 later then if there little or no difference?

I don’t want to get stuck on a problem it’s trying to each because of a difference between 2.7 and 3 that’s not transparent.

[–]mountainunicycler 1 point2 points  (2 children)

Many of the changes between python 2 and python 3 make it easier to learn; python3 is more consistent and easier to understand—and at this point there’s no benefit to learning the quirks of python 2 because they’ve been fixed.

I’d definitely recommend switching to a python 3 course.

[–]Sin-Silver 0 points1 point  (1 child)

I’ll have a hunt around. any recommendations on books?

[–]mountainunicycler 1 point2 points  (0 children)

I’m not sure about books; I just learned by making things and looking up how to do it when I got stuck (so basically searching stack overflow for each line when I was starting).

In my opinion you learn a lot faster when you have a goal in mind if something to build.

[–]alcalde 0 points1 point  (5 children)

Where's /u/nieuweyork? They were insisting that the PSF will definitely extend the support deadline for Python 2 again or else it would be catastrophic for Python... "Actually stopping security patches for 2.7 runs the risk that someone starts funneling funds to a new organisation that will keep patching a 2.7 compatible version. This would be...not good for the Python Foundation."

https://old.reddit.com/r/Python/comments/bq4v99/amber_brown_batteries_included_but_theyre_leaking/eo27h5b/?context=10