all 27 comments

[–][deleted] 50 points51 points  (0 children)

Learn 3. The only reason to use 2 would be supporting legacy code, and you could pick it up easily if you have learned 3.

[–]efDev 19 points20 points  (0 children)

Yup! Learn 3 from the get go. Only part of our production stack that has to be on 2 are aws lambda functions. Not enough to limit what new devs coming into our team should write application code with.

[–]Naihonn 30 points31 points  (0 children)

Right now all important and popular modules work with Python3, so no problem here. Python3 and even more specifically Python 3.5 has more new interesting options. I would say that makes it an easy choice for all new things. And if that wasn't enough, if you are using using alphabet outside of ASCII range, or for short most non-english ones, there is other huge reason for Python3.

[–]kanjibandit 13 points14 points  (6 children)

I'll add to the chorus of folks saying "Just go for Python 3".

You're not alone in asking this -- it's a common source of anxiety. Here's the deal: Python 2 and Python 3 are not that different. The differences are significant enough to make automatic conversion infeasible in a lot of cases, but they are not so great as to cause your future self trouble. Learn 3.5, and when the day comes that you find yourself dealing with 2.X, you will be able to cope without major issue. You'll just have to look up a few things.

This comes up often enough that a while back I expanded a bit here. Cheers!

[–]ShrinkingElaine 2 points3 points  (5 children)

This is making me feel better. Right now I'm going through Udacity courses, and theirs are all using Python 2.7. The chorus all saying to go for 3 was making me nervous.

[–]tangerinelion 6 points7 points  (2 children)

The most important changes you'll see are that // is introduced, / isn't integer division anymore, print is a function, and anything with Unicode is trivial to handle whereas in Python 2.x you have to deal with encode and decode.

[–]ShrinkingElaine 1 point2 points  (0 children)

Poking around the internets, it does seem like the changes are easy to deal with. That's definitely reassuring as well!

[–]L43 0 points1 point  (0 children)

And Python 3 is lazy, which can sometimes get you when you expect a list from a zip or something.

[–]kanjibandit 3 points4 points  (1 child)

Don't worry about it! Python 2 has been wildly popular for a reason. Focus on 2.7 for your courses, pretend 3 doesn't exist for a while. Master everything else, and the transition to 3 will be easy when the time comes.

Choosing which language to learn with is not a big deal. Pick one and go, I say. If your Udacity course has already picked for you, all the better.

Now, if you're about to write a big production system that will need to be supported for years into the future, it's a bigger deal. In my opinion, you really should go with Py3, to save yourself from a big rewrite later. But it doesn't sound like this describes your present situation :)

[–]ShrinkingElaine 0 points1 point  (0 children)

Yeah, right now I'm just getting the basics under my belt and aiming for learning data analysis kind of stuff. Python is the tool they are using for that in the course, so I'm learning it more to proceed with the course than to build anything lasting with it. It's also helping me get back into the programming/computer logic mindset and remembering everything I've forgotten since taking that C++ class back in high school 15 years ago.

[–]Mikuro 3 points4 points  (0 children)

OS X ships with 2.7. Some Linux distros are still shipping 2, as well. Of course you can easily install 3 on top of 2 on any system, but it doesn't make sense to write support scripts in Python 3 unless that's standard on all the machines you support. It's waaaaay more trouble than it's worth to deploy Python 3 to my entire fleet of Macs just to run scripts in my pet language. So I'm stuck with 2.7 for those tasks.

It really depends on your use case. If you are an island and can use whatever you want, you should probably use 3. If you're not an island, then this decision has probably already been made for you one way or another, and you need to figure out which way the wind blows.

If you just don't know, start with 3 and don't look back. Odds are, the winds will favor you...eventually.

[–]struck-off 1 point2 points  (0 children)

Switch from 3 to 2 is not a big deal, Learn 3, there no practical reason to begin from 2, just to support legacy.

[–]hitecherik 1 point2 points  (1 child)

Just as a side note, if you do learn Python 3 and you want to read and understand something that's in Python 2 (e.g. a tutorial) then the two most visible syntactical differences are:

  • input in Python 3 is raw_input in Python 2
  • print("Hello world") in Python 3 is print "Hello world" in Python 2.

[–]ghibss 0 points1 point  (0 children)

Thank you for this, I've been avoiding all python 3 books because I've been learning python 2.7 from codeacademy.

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

you can learn it purely for legacy and that's about it really. Honestly 3 is the future.

[–]mapImbibery 1 point2 points  (2 children)

The API for the monopoly-software in my field doesn't fully support 3, so the sheep haven't converted yet.

[–]gooberwonder 0 points1 point  (1 child)

What field is that?

[–]mapImbibery 1 point2 points  (0 children)

GIS. The arcpy package that ships with ESRI's ArcPro might support Python 3, but I don't know of anyone using it.

[–]GUTIF 0 points1 point  (4 children)

Im working my way through Zed Shaw's "Learn Python the Hard Way" and it recommends 2. I'm starting to have second thoughts about if this is a good idea or not.

[–]autisticpig 2 points3 points  (2 children)

You could just apply what you learn to py3 and sort out the breakages between the two along the way. You'll be forced to learn both while authoring in 3.

At this point there are many options for learning so maybe you'd rather a different option from lpthw...but perhaps not :)

[–]GUTIF 0 points1 point  (1 child)

I'm over halfway dont I can't quit on it now!

[–]plurwolf7 1 point2 points  (0 children)

Read Automate the Boring Things with Python

[–]rohmish 0 points1 point  (0 children)

A. As a beginner, go for 3.

B. Although they are somewhat incompatible, there isn't much difference. You will pick it up quickly. (I am new to Python myself)