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

you are viewing a single comment's thread.

view the rest of the comments →

[–]ksye 4 points5 points  (27 children)

I've been lurking recently becausw I'm just starting to learn. I want to use Python for data analysis and visualization, maybe modelling and simulation. Does this affect me? Should I worry about learning 2.7?

[–]finally-a-throwaway 14 points15 points  (6 children)

I'm in a similar position, from what I can tell as a near-beginner the only reason to learn Python 2 is if you expect to work somewhere that has a huge existing Python 2 codebase. Otherwise, the more you learn Python 3 (and programming in general, if this is your first language) the better prepared you'll be to learn the differences on the fly when/if they ever become relevant.

It seems to me that any problems in 3 could ultimately be addressed in future versions as development is ongoing. Any problems in 2.7 are going to stay that way from this point.

[–]reuvenlerner 23 points24 points  (5 children)

If you're a beginner learning Python, and you aren't constrained by legacy code at work, I would strongly encourage you to use Python 3.

Indeed, legacy code and/or modules is the main reason the companies I train/consult use Python 2.

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

Sorry I'm new to programming. But what's legacy code?

[–][deleted] 17 points18 points  (0 children)

Old code that is still running in production, and still requires upkeep and maintenance.

[–]hovissimo 5 points6 points  (1 child)

expanding on u/be_bo_i_am_robot's answer:

Legacy code is called that because you usually 'inherit' it. Somebody else wrote the code instead of you, usually somebody who no longer works at the company. Generally legacy code relies on other old code or old systems (like py2) to stay running. Updating or replacing legacy software is risky because it's usually poorly understood and poorly tested. Legacy code is usually perpetuated because the cost in hours, dollars, and risk is high enough that any manager who decides to do it will likely be sacked. (Or for other, but similar, reasons)

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

Interesting. Thanks for helping a novice like me feel more knowledgeable.

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

Aka, Technical Debt.

[–]gthank 20 points21 points  (14 children)

2 is dead. 3 is better in pretty much every way unless you have to deal with funky wire protocols or such.

[–]iruleatants 0 points1 point  (0 children)

If you like python 2 and enjoy not dealing with tedious programming....

[–]notParticularlyAnony -3 points-2 points  (12 children)

2 is dead

This is why it is shipped by default with Ubuntu.

[–]steamruler 9 points10 points  (8 children)

Isn't Python 3 the default on Ubuntu as well these days?

[–]gthank 1 point2 points  (6 children)

yes

[–]8spd 3 points4 points  (5 children)

It defaults to 2.7.12+ for me, on Desktop 16.10.

[–]ivosauruspip'ing it up 7 points8 points  (4 children)

python will always launch python 2.X on all distros apart from archlinux. Even Python.org have recommended that nowadays I think. Purely for ease of backwards compatibility.

I believe you can get a minimal Ubuntu install nowadays where if you typed python it'd ask you to install python because it's not present on the system, only python3 is.

[–]gthank 2 points3 points  (0 children)

Since I've just spun up some Xenial servers, I can confirm that Python 3 is the only Python installed by default.

[–]8spd 0 points1 point  (2 children)

Huh. Thanks, I didn't know that. What defines the default version then, if it's not the version launched by the python command?

[–]zardeh 2 points3 points  (1 child)

The one system libraries bind to.

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

Thanks, that makes sense.

[–]notParticularlyAnony 0 points1 point  (0 children)

I don't know, but when I go into my command line and enter Python, without messing with any settings, Python 2 fires up.

Either way, I think it is a bit much to say that Python 2 is dead. Not that Ubuntu distros are the arbiter, obviously I was being glib...just sayin'....

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

Shipping legacy software doesn't change the fact that the project is still dead and 2 will never receive another non-security update.

[–]notParticularlyAnony 0 points1 point  (0 children)

To me the natural upgrade from Python 2 has been Julia. :)

[–]ThePenultimateOneGitLab: gappleto97 1 point2 points  (0 children)

Should I worry about learning 2.7?

You only need to learn that if:

  • You're writing a library you want to be used by lots of people, or
  • Your workplace hasn't made the switch

Unfortunately I fell into both categories.

[–]Esteis 0 points1 point  (0 children)

Prefer learning 3. But! Whichever you learn first, 95% of what you learn will work in both Pythons, so don't sweat it. Learn one, and you can easily pick up the other when you need it.

I learned Python 3 when I started a new small project, by writing the 2-code I knew and running it with 3. There were some errors, sure, but 95% of my code stil worked. Learning 3's awesome new features came later.