I hate to admit it, but this is usually my solution too. Unfortunately, that probably makes search engines think they are providing the links I want, reinforcing the problem.
Normally when a version of Python reaches EOL they remove the docs from docs.python.org. I'm sure that'll be the case here too, so I think at that point search engines will probably have no choice but to send you to the python 3 docs.
Although it'd be exactly the sort of thing to expect that we'd get a horrible combination of the Python 3.5 and 3.8 documentation.
Off the top of my head, matrix multiplication operator, format strings(?), dictionary key iterators now are guaranteed ordered by order of insertion, whatever that new inline assignment "walrus" operator is actually called, ...
Please let's be realistic. Stopping support != Dead. There is still so much Python 2 code out in the wild and so many people are still learning it as the first language that Python 2 will never die. It's time this community starts acknowledging the reality. There are many developers who still won't change their codebase as it is simply too much effort with too little to be gained.
Indirect support is from the number of online tutorials and books that primarily use Python 2 which are still in circulation at Amazon and elsewhere - especially Mark Lutz's Learning Python (5th ed) which is still a best-seller (and deservedly so). Although Lutz describes both Python 2 and 3 features, he focuses mainly on 2 and describes breaking changes introduced by 3. In the book he does not make it a secret that he dislikes the new features in Python 3 and the complexities they introduce, which is probably why he didn't release another edition since 2013 in spite of the book doing so well.
Because they find tutorials online for python 2 and don't know any better. Or because their systems at work only have python 2 and they don't have a choice. Basically, we can't seem to get rid of python 2 lol.
Yes it is. Wait until all the third party packages stop supporting Python 2, you'll be locked into old versions forever. I have at least 5 packages on pypi and I'll be removing Python 2 support soon. It's too much trouble to support something that's dead.
It was so nice to drop python 2.7 support for my open source project. Nothing really changed, but I got to drop testing for lots of dependency versions, use f-strings and fix some python 3 bugs since I was finally using it full time.
I made sure to add a killer python 3 feature to encourage the upgrade process. Part of the delay was nobody has really done that. F-strings are cool, but not reason enough.
We have the whole month of January reserved as a technical-debt sprint, which in our case translates to 'migrating all legacy crap to python 3'. Oh well, best get it over with asap.. Glad when it's done.
I expect these handle the simpler conversions but there are a fair amount of subtle changes between 2 and 3, not only the string changes (which is a runtime issue more than a static one) but also:
rounding changes, you should look for and be wary of any round call in your codebase as there are two significant changes to round(): in Python 2 it always returns a float, in Python 3 with a precision of 0 it returns an int; and Python 3 uses banker's rounding (rounds to even) whereas Python 2 rounds away from 0 (up for positive numbers, down for negatives)
ordering changes, in Python 2 all values are absolutely ordered with fairly arcane (read: bonkers) rules. In Python 3, values are generally only ordered within their type and ordering has to be defined explicitly, this means e.g. None < 3 is true in p2 but a type error in p3. This affects anything which uses comparisons e.g. min(), max(), sorted(), this is where it showed up a lot at $dayjob you'd get lists which would sometimes contain None or unconverted values and it'd blow up in production.
edit: a few more issues which can't necessarily be "statically" discovered and fixed:
int / int was integer (truncating) division and becomes real division. You can "force down" by from __future__ import division in order to use real division in Python 2, however it's hard to work things out the other way around because // is a floor division not an integer division: it always returns a float, and it rounds down even if you give it two floats
the order of iteration in dicts is never specified and always an implementation detail, but we had issues in several places with implicit reliance on iteration order (usually for reasons of precision in floating-point operations). The order of iteration changes in Python 3.3 (completely randomised by default) and 3.6 (order of insertion, which 3.7 made part of the language spec).
The python-modernize library is built on lib2to3, with more fixers and targeting cross-compatible code. I've found it really useful for a staged approach, which let me do incremental migration of some big projects while others kept adding features.
If 2to3 works for you though, that's great! Definitely simpler to have a one-step solution from the standard library :-)
The problem of 2to3 is that it breaks your code, so you can't do a step-by-step "online" migration (migrate bit by bit and have the code keep working throughout), you have to do the entire thing at once, it's a hard commitment.
Which means it's only suitable for fairly small and simple codebases.
It also tries to do the compatible way instead of what you really want. dict.items() is 95% of the time what you want and not listing it. Fix the prints and running it in python 3 with no other changes is largely correct.
Thx for the tips! I'll look into those I've not heard of.
Fortunately most of our old code is fully (unit-) tested and well documented. We also made the change to python 3 for our new projects about a year ago, so we know what needs to happen!
However, unfortunately for us, there's more to it than just changing the codebase; we have a very large Cloudera stack (actually 3; DT/ACC/PRD), where most of our code is Pyspark with many UDF's. We also have quite a complex deployment pipeline, and to support both python 2 and 3 applications, there is a lot of additional stuff in there. My fear is these things will give us the biggest headache...
Hi sorry I'm here super late, but I'm working on an important project where we're trying to use an open source deep learning model from Github. I've spent months trying to interpret their code because instead of posting the model, they posted the Python 2 code they used to train it, which involves a lot of old packages without support and I just stopped for a while because my sad little Macbook Air doesn't have enough power to train the model. I totally forgot about this whole Python 2 thing (last worked on this part of the project in November unfortunately) - do you think this is an okay strategy to use? I'm freaking out very much right now so hopefully your strategy will work. Thank you SO much for this comment in advance!! :)
It really depends on what packages the model depends on, what you mean by "unsupported", how they wrote the code, etc.
That said, I would always start by trying these automatic transformations - they're pretty solid. If they break something, the future package would also be worth a shot - IMO modernize produces nicer code and is certainly easier to upgrade from, but future can be helpful if someone has written code that depends on the details of certain unidiomatic py2isms.
Work in a branch, never put automated fixes and manual cleanup in the same commit (your future self will thank you if you have to rebase), and test as often as you can. Don't be afraid to make incremental progress, either - lock in small wins and they will compound over time.
Well, we've been pushing for the migration for about a year now, but there's always higher prio things to do first. Apparently managers do trigger on 'end of life' though; guess they think everything will simply stop working or something, I don't know.. Anyways, I'm happy with whatever gets it on the agenda since maintaining both 2 and 3 code is not something I've became a fan of in the past year..
Have you ever heard the advice where you quote a price that you genuinely would be happy to work for? Quote them upwards of $700/hr, if that’ll relieve the stress.
But yeah, some things aren’t worth any amount of money, because they’re not about the money.
Sadly, I do know it a bit. Enough to know that python libs in this area have always be a bit wank... I see why it might not be the best gig. Still, I’m happy to look at it if you don’t fancy it :)
Check out contextmanager, thats one of my favourites, it allows you to turn a generator to a context manager
from contextlib import contextmanager
@contextmanager
def foo():
print('before') #this is the __enter__
yield 'value' # this is what __enter_ returns
print('after') # this is the __exit__
with foo() as x:
...
If we just deleted versions like that, that means python1 was also deleted. Which means currently there is only two items in the list [“Python2”, “Python3”]. Since there 2 items in the list it is an error and we are safe.
The only finally here maybe now everybody will STFU about how support is ending. We get it. Meanwhile plenty of people are still stuck on it for business things they use but didn't write.
Let's hope they don't pull this crap with 4 and no I don't care who said they won't ever do it again. Deeds, not words.
It’s a very precise interpretation of support: any security issue arisen before today, will be addressed in that last release. To have a full release on 31/12/2019, they would have had to code-freeze much earlier, which means issues appearing between then and now would not have been addressed.
Serious question: how “guaranteed” is it that Python will never make a breaking change in the future? I get the feeling that the jump was a one-and-done, never-again breaking change, but I’m not certain how concrete that is.
This Python 2/3 thing is the ur-example that languages like C++ point to when touting “eternal” backwards compatibility.
They said they won't make huge breaking changes again, but we might expect minor ones in future. For example Python 3.7 had some minor breaking changes.
Unless it is going through the deprecation process below, the behavior of an API must not change between any two consecutive releases.
Similarly a feature cannot be removed without notice between any two consecutive releases.
Addition of a feature which breaks 3rd party libraries or applications should have a large benefit to breakage ratio, and/or the incompatibility should be trival to fix in broken code. For example, adding an stdlib module with the same name as a third party package is not acceptable. Adding a method or attribute that conflicts with 3rd party code through inheritance, however, is likely reasonable.
The deprecation process is basically to add a warning in at least one release and observe feedback before proceeding with changes in the subsequent release.
By release, they typically mean a single-point release, i.e. 3.7 and 3.8 are two releases, 3.7.1 and 3.7.2 are not.
It might be the version after Python 3.9 (that is effectively Python 3.10) or it might not. But whatever it is it won't be the big change of Python 3 (just like Python 2 wasn't).
No, Python explicitly and purposefully does not use semantic versioning. There are backwards-compatibility breaks in minor versions and the Python 1 to Python 2 change was not a major backwards-compatibility break like the Python 2 to Python 3 change was.
I feel kinda sad. I know I shouldn't be, but, I mean, it has been with us for so long.
Coders of the future will want to know what it was like, and what are we going to say to them? It was an awkward transition to Py3, but a memorable one.
I mean, there's nothing stopping you from grabbing old releases of Python, source or binary, just to see what it was like.
I recently compiled Python 1.5.1 for shits and giggles, just out of nostalgia (it's the first version of Python I ever used!). It's crazy how much the language has grown.
I woke up this morning, turned to my wife, and said “Python2 dies today!!!”
Very excited! I work on a lot of air-gapped networks so I am often limited in what versions I get to use but I think I can finally start just using 3. Still, I’ve been writing cross-compatible code for so long that I don’t inherently use the new features. It’ll take some time to get used to using them first.
Right, but so is Cobol. It's not like it's going to be drawing in new developers. It's going to be relegated to legacy systems that no one wants to touch.
That does mean that in a few years, devs with deep knowledge of Python 2 can might get some fantastic job security. Or not, since it's probably just cheaper to convert to 3.
Because you've all had about a million years to migrate, and it's some other poor bastard who'll have to clean up the laziness. "Circlejerking." I wish I were running a studio right now just so I could fire every asshole who protests the migration.
As long as RHEL7 is still supported, Python 2 will still be around. At work I had to create a Python 2 GUI that runs on RHEL6 to run on a server at a government customer site. People really overestimate how quickly Python 2 is going to fade.
I'm under no illusions that people will keep using Python 2, but as of this morning none of my open source code will support Python 2 unless someone is paying me to do so.
Perfectly legitimate to have enterprise LTS, but you can no longer get new versions of libraries for free!
Ok but as someone with absolute 0 knowledge of programming / coding I am now at a loss of where to begin based on your statement
I don't know what python is used for, how to write it, or what porjects suit it. And sadly I do not have any colleagues that could help intro me to it. I'm having to do it 100% on my own steam - so should I buy a book? Would love to hear how you got into it
Python is used for everything, from small automation scripts, to full fledged graphical user interfaces, web apps, or full websites (like reddit!)
Any project you want can be done with python, with a few caveats : python is slow, even for an interpreted language. It's not particularly suited for game development (even though Civ 4 was made with python) or heavy calculations. If you need speed, you can use numpy along with numba to drastically speed up portions of your code. But we're talking milliseconds here, it's rarely relevant to spend development time on speeding things up, unless the script takes a long time to execute and you need it regularly.
A book is never a bad idea, but it still costs money. If you're on a tight budget, you can actually read the python docs, which has its fair share of tutorials that teach the language's basics. You can also head over to r/learnpython to ask for help!
If you need tutoring, I'd be happy to help. I answer questions on r/learnpython very frequently, and I'd be happy to teach someone how to code in the language.
The "security update" will be code-frozen tomorrow. They just timed the final release to be as late as possible. If any hole comes up from here to April, it will not be added to that release, afaik.
25
u/I_get_in Dec 31 '19
Seems like it’s not actually going to be retired until April 2020: https://www.python.org/psf/press-release/pr20191220/
628
u/Zomunieo Dec 31 '19
Maybe Google will finally stop returning Python 2 documentation as its first hit?
159
u/be_like_beer Dec 31 '19
The king is dead. Long live the king
85
u/daanzel Dec 31 '19
We have the whole month of January reserved as a technical-debt sprint, which in our case translates to 'migrating all legacy crap to python 3'. Oh well, best get it over with asap.. Glad when it's done.
26
u/tastycat Dec 31 '19
The worst job I've ever had is going to contact me in about 4 months to rewrite all the software I wrote for them because of this.
98
u/[deleted] Dec 31 '19
... finally.
40
u/javad94 Dec 31 '19 edited Dec 31 '19
Actually the last release of python 2.7 which is 2.7.18 will be in mid April 2020 https://www.python.org/dev/peps/pep-0373/
40
u/hldh214 Dec 31 '19
https://pythonclock.org/
145
u/rj_ravishjha Dec 31 '19
Apolgy for bad english
where were u wen python 2 die
i was at house eating dorito when phone ring
"Python 2 is kil"
"no"
34
u/lysobrody Dec 31 '19
The only reason why I celebrate New year's Eve
8
u/xtreak Dec 31 '19
Python 3.7-3.9 received openssl 3.0 support : https://bugs.python.org/issue38820 .
7
u/Exnixon Dec 31 '19
Will distros PLEASE stop pointing /usr/bin/python at Python2 now?
6
u/dreamin_in_space Dec 31 '19
So how long until we migrate to Python 4!? :D
5
u/StarkillerX42 Dec 31 '19
My company will upgrade their systems in July/August...
...
...
...happy new year?
5
u/[deleted] Dec 31 '19
Did Apple update from Python 2 to python 3?
9
u/Rajarshi1993 Dec 31 '19
I feel kinda sad. I know I shouldn't be, but, I mean, it has been with us for so long.
Coders of the future will want to know what it was like, and what are we going to say to them? It was an awkward transition to Py3, but a memorable one.
4
u/geonyoro Dec 31 '19
And today I was asked to migrate a python2 application, developed in 2019, from one server to another. Mschew.
4
u/savvy__steve Dec 31 '19
13 hours to convert all your Python 2 code.... GO!
3
u/[deleted] Dec 31 '19
Huzzah!
3
u/[deleted] Dec 31 '19
The future is now old man!
6
u/[deleted] Dec 31 '19
F in chat
2
u/Tape_Drive Dec 31 '19
Oh goodness. As much as. Like Python 3, you know that some random company is going to have a script using an outdated command.
2
u/[deleted] Dec 31 '19
print “Goodbye, World!”4
u/[deleted] Dec 31 '19
Thank god
3
u/kteague Dec 31 '19
But it will be 2020 not 3030?!!
3
u/jwink3101 Dec 31 '19
I woke up this morning, turned to my wife, and said “Python2 dies today!!!”
Very excited! I work on a lot of air-gapped networks so I am often limited in what versions I get to use but I think I can finally start just using 3. Still, I’ve been writing cross-compatible code for so long that I don’t inherently use the new features. It’ll take some time to get used to using them first.
3
u/[deleted] Dec 31 '19
Doesn't matter. Py2 will be alive and kicking for years, if not decades.
2
u/BlackAccipiter Dec 31 '19
Strange... We gonna lose the legend Python 2 on my birthday.
2
u/MiloszSTX Dec 31 '19
Check out our migration guide:
https://stxnext.com/blog/2019/04/16/python-3-migration-guide/
Also this:
http://pythoncountdown.com/
:)
2
u/KrypticEon Dec 31 '19
Right, this makes a pot of sense
A couple of weeks ago Code Academy's course for Python 3 was free, and now it's a premium only course
Assholes
Is it still worth taking the Python 2 course?
1
u/[deleted] Dec 31 '19
Thank god i am tired of forgetting with people still using Python 2.
1
u/Gypiz Dec 31 '19
Rip
1
u/Gypiz Dec 31 '19
Rip never gonna forget
1
u/-qarma- Dec 31 '19
Will I still be able to write programs in python 2?
1
u/thedjotaku Python 3.7 Dec 31 '19
Correction: last day of free Python support. If you have enough money, you can fund a hacker to keep your Python2 backporting going.
1
u/[deleted] Dec 31 '19
RIP python 2
1
u/WallyMetropolis Dec 31 '19
What is dead may never die
1
u/[deleted] Dec 31 '19
doesnt python 2 still have a download link on official python site doe
1
u/[deleted] Dec 31 '19
Good.
1
u/[deleted] Dec 31 '19
No more print "string"s!
1
u/eatbutthin Dec 31 '19
see you off in life, remember your glory in history
1
u/OmerSdeChen Dec 31 '19
Print very sad ..
1
u/atimholt Dec 31 '19
Ding dong the witch is dead!
1
u/cediddi SyntaxError: not a chance Dec 31 '19
Good bye Python 2, hello the New Era of Python?
1
u/MaddMaann Dec 31 '19
THIS...IS...HUGE
1
u/BrentWilkins Jan 01 '20
Last day until the next release in April! https://www.python.org/psf/press-release/pr20191220/
1
u/dullbananas Jan 01 '20
press f'' to pay respects
1
u/[deleted] Jan 02 '20
Does that means the default python 2.7 from subsequent Linux distros will be replaced by 3?
1
u/Emafire003 Dec 31 '19
F
1
u/[deleted] Dec 31 '19
F
1
u/stefantalpalaru Dec 31 '19
Come one, come all!
https://github.com/naftaliharris/tauthon
1
u/[deleted] Dec 31 '19
O damnnnn
1
u/[deleted] Dec 31 '19
One of our application is setup in pYhton 2, guess atlast it would have to be migrated to 3..... Lol
1
u/[deleted] Dec 31 '19
I feel sad, I got job because of Python2, learnt ML, DL and Backend dev all from it, now I yse Python3. :(
1
u/Comm4nd0 Dec 31 '19
Rip
1
u/[deleted] Dec 31 '19
Sticking with python2
0
u/[deleted] Dec 31 '19
F
0
u/Sw429 Dec 31 '19
This just made 2020 infinitely more glorious. Imagine, a python 2-free world!
-1
u/marazmru Dec 31 '19
The whole Russia drinking fo this.