Hacker News new | comments | ask | show | jobs | submit login

I'm planning to spend my free time in the next couple of months learning Python, should I only learn Python 3?



Pretty much. No reason to look into Python 2 when most of the useful libraries already support Python 3, which is the point of the OP.

And you'll save yourself a lot of 2-to-3 fatigue we've all been struggling with.

Tip: there's a Chrome/Firefox extension to redirect all Google results from Python 2 documentation to their corresponding entries in Python 3 docs.



Yes. But there are very few differences anyway. The only thing is that there is not 100% backward compatibility, which is why we get articles like this. For computers that is a Big Deal, but for humans it is really easy.


While many companies still use Python 2.X, they are sufficiently similar that I would recommend learning 3 and retrofitting your knowledge set if necessary later on.


You got many rational reasons for starting learning Python with Python 2:

- It is easier syntax and string-handling for beginners. Else, look for someone who started learning Python with Python 3 and ask them about their experience. You probably won't find many here.

- There are more resources online for learning Python 2. Many MOOCs happily teach Python 2.

- ~5% of very popular libraries are not ported yet. Many unpopular libraries will never see a port. Some use this as an argument for switching to Python 3, but that is like being blind and being told to be happy that the number of inaccessible websites went from 10% to 5%, telling you there is no reason to look at those inaccessible websites.

- Many companies still use Python 2.

- Many distributions come with Python 2 installed.

- Switching from Python 2 to Python 3 is but a minor annoyance, mostly in paying the print-tax. Switching from Python 3-exclusive code to Python 2 is downright hell.

The reasons not to learn Python 2 and start with Python 3 are:

- Python 2 is deemed legacy and will see no security patches after 2020.

- Python 2/3 is painful for some developers and maintainers. They'll cloud this is in a "move Python forward" that is reminiscent of the "move the web forward"-movement (by deliberately breaking designs for older browsers, or forcing the user to download a font to make their layout work properly).

- Python 3 proponents don't care about you learning a new language, they care about adding 1 to the dwindling adoption count of Python 3. They see Python 2 as competition, a ghost from the past. Here the reasons they give you have nothing to do with you wanting the easiest path to mastering Python. These are either political or selfish reasons.

You'll be in the minority on HN if you go Python 2. But realize that HN's stance on Python is not a beginners stance. They use features of the language that you won't use for another 2 years. They have very strong opinions on 2 vs. 3, alternating between calling it a completely different language, and the same (but improved) language, whenever it suits their argument.

Pick wisely.


Yes.


As someone who asked the same question a few years back (and gladly received the answer: Python 2), I'd suggest you learn both.

Does not matter which language you start in, as long as you can write Python 2/3 compatible code. Perhaps starting with Python 2 (and the fantastic "LearnPythonTheHardWay") helps with this. You'll just have to unlearn a few Py2 warts like xrange and using print statements with ellipses.

You are not being progressive, nor doing your users a favor, if you go exclusively Python 3. Even if the language owners decided not to be backwards compatible, your code still can be (and, IMO, proudly should).

As you arrive to a point where you want to use Python 3 exclusive language features, you'll be at least advanced in Python enough, to form your own well-informed opinion on the matter. I myself don't feel like library support for Python 3 should be the deciding factor for a switch. That's like switching to exclusively designing for a certain browser version, because most websites render just fine, leaving users stuck on IE6 without accessible content.


> I'd suggest you learn both.

I'd suggest OP learns Python 3 and try really hard not to look at Python 2 ever, which hopefully shouldn't be too hard in 2017.

> as long as you can write Python 2/3 compatible code

Maintaining a Python 2 and 3 compatible codebase in a PITA. OP wants to learn a new language, presumably to build things with it. But your advice is that they acquire insight of all the mistakes of a language that was released 7 years ago (that's for 2.7, 2.0 was release in 2000) and will reach end-of-life in 2 years. I'd really like to understand why in the world you would want to learn Python 2 and its “warts“, to then discover that all this stuff are just unnecessary pain points that were removed/refactored/cleaned up in Python 3. In my opinion, Python 2 and 3 are two different languages and should be treated like so.

> [not] doing your users a favor, if you go exclusively Python 3

Actually you are. If you start a project today and make it Python 2 + 3, you are forcing your users (most of whom in 2017 would be proud Python 3 users anyway) to cope with a. all the bugs introduced by the compat code you have to write and b. the delayed releases/bugfixes caused by the subtle Python 2/3 discrepancies you'll face one day or the other.

I will make no comment on the IE6 comparison: this isn't about corporate employees or banking apps from the 90's.


> Maintaining a Python 2 and 3 compatible codebase in a PITA.

I maintain multiple Py 2-3 compatible codebases, both academically and commercially. It's not hard, because I develop in Python 2, while writing Python 3 compatible code.

Python 2 is a beautiful language as powerful as:

   import antigravity
   print "Hello, world!"
There is nothing a beginner can't do in Python 2 that he/she can do in Python 3.

If Python is a different language and should be treated like so, then I don't want to switch to this other language, or have a project support two different languages (I'd switch to Go if having to switch languages). For all intents and purposes: Python 2 works just fine. Google did not need Python 3 when they first released TensorFlow a year back.

> If you start a project today and make it Python 2 + 3

Then you are compatible will the largest amount of users. That's what matters to me: Somebody on a fresh install being able to pip install my library, no matter if it is Python 2.7+ or 3.4+. All other reasons are politics.

> this isn't about corporate employees or banking apps from the 90's.

No, it's about banking apps from the 00's and 10's.




Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: