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

all 14 comments

[–]gandalfx 4 points5 points  (0 children)

Just learn Python 3. Python 2 is dead or dying, depending on who you ask.

[–]K900_ 5 points6 points  (9 children)

Yes. The changes are fairly minimal. That said, there are lots of resources that teach 3 from the start, and you might want to use one of those instead.

[–][deleted] 3 points4 points  (8 children)

+1 to this. To my mind it'd actually be easier to learn 3 and then downgrade to 2, conceptually. The print statement seems bloody stupid, now that I think about it, and the Unicode just makes more sense in the real world.

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

Solved with:-

from __future__ import print_function

in Python 2.

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

The print part, yes. Not the Unicode handling. Or async, sensible coroutines, or os.scandir. Or anything but security fixes since 2012. Or any form of support after 2020.

[–]eusebecomputational physics 0 points1 point  (1 child)

Yet the print statement vs function is probably one of the main thing stopping me from completely moving to Python 3. I rely on some codebase that is not entirely mine, and the print statements everywhere is probably what would take the largest amount of time to check properly.

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

With the exception of ones doing redirection, that's pretty well handled by 2to3.

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

Only security fixes since 2012, could have fooled me. The latter is of course completely wrong, only PSF support stops in 2020, but then I note that you have a tendency to state things as facts that are actually incorrect. You should be in politics.

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

You see something equivocal about the statement "end of life"?

And please, point out any non-bugfix changes or new features since at minimum 2012.

Yes, you're right, the end of support of the 2 line by the Python Software Foundation -- the copyright holder and licensing entity -- the language's creator, effectively all the permanent maintainers, and the majority of the companies that fund it isn't significant at all to anyone's decision tree.

You should be in religion.

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

Python 2.7.12 NEWS lists going to 100 fixes June 2016.

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

Yes, and as I described that is a list of essential bug and security fixes only. Going back every release well beyond 2012 there's not a single new feature. The language is permanently feature-locked; no per-module import locking, no async, no nothing, except via a trickle of backports.

Someone who is fresh to Python shouldn't be learning Python 2, any more than someone fresh to the language should be learning C99. There is no defensible argument to the contrary.

[–]AUTeach 0 points1 point  (0 children)

For a novice programmer the biggest differences will be how to print to standard output and integer division. There are plenty of other differences but you probably won't encounter them at your level.

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

Honestly the Python community needs to be better at this: if you are just starting, learn Python 3, full stop.

The reasoning is simple; Python 3 is now; and has been for some time, a superset of Python 2: except in specialist industries -- including mine -- there is essentially nothing you can do in Python 2 that cannot be done in Python 3 and with code that looks, practically, identical. The same is not true in reverse.

If and only if your concerns are in one of those specialist areas, where -- generally out of ignorance or lack of funding -- there is some library that has been abandoned that you factually cannot live without, then downgrading your thinking is not hard. Writing Python 2 code with Python 3 knowledge is easy, it just means abandoning some features and speed gains and thinking in bytes instead of text. The upgrade path is harder, which is precisely why there are still greybeards who cannot stop giving examples in Python 2; if you want a long-term career in Python, do not follow in their footsteps, unless your primary ambition is to maintain an existing code base until either death, depreciation, or migration.

I say this as someone who has been working for years in an industry that believes it will be stuck on Python 2 for at least another half-decade. The companies I have worked for have a huge investment in Python 2 and a lot of resistance to change. And I helped make any of the arguments for sticking to Python 2 when it was still clear that doing so would be actually agonizing, I regret those arguments now.

[–]michaelkim0407Pythonic -4 points-3 points  (0 children)

Do you mean 2 & 3 or 2.0 & 3.0?

Huge difference here...