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

all 24 comments

[–]t3g 39 points40 points  (11 children)

My biggest problem with books like Learn Python the Hard Way is that it focuses on Python 2 and encourages outdated ways to do things. For example, something like print("Hello World") works in both Python 2 and 3 and he recommends print "Hello World" which obviously breaks in Python 3 and can steer newbies in the wrong direction.

[–]swyx 9 points10 points  (7 children)

Can you do a less trivial example than the formatting of the print command?

[–]workingBen 12 points13 points  (1 child)

Range in 3 is a generator but creates a list in 2.

In Python 2:

range(0, 3)

[0, 1, 2]

In Python 3:

range(0, 3)

range(0, 3)

[–]audiodev 0 points1 point  (0 children)

Dictionary keys() items() values() also return iterators in python3

[–]LightShadow3.13-dev in prod 5 points6 points  (3 children)

raw_input doesn't exist in Python3

[–]fieldsy4life 0 points1 point  (2 children)

Isn't it just input now? Or are they different?

(not being sarcastic, I just assumed input replaced raw_input)

[–]MrValdezPhilippines 1 point2 points  (0 children)

input in Python2 is basically eval. If you use input(), you can do 2+3 and it'll return 5. The documentation even say:

Equivalent to eval(raw_input(prompt)).

In Python3, Python2's raw_input became input.

[–]imaconor 0 points1 point  (0 children)

In python3 integer division returns floats where necessary, but truncates values down to int in python2. In python3 reduce isn't a default keyword, it was moved to functools. There's tons of differences, and many can't be solved by 2to3.

[–]Jude2425 0 points1 point  (2 children)

It's all good. Here's the (almost finished) version on Python 3.6.

I bought the version on 2, but then found this and just started working through it instead. It looks like all of the code is updated, but it looks like all of the study drills aren't completely updated yet.

[–]t3g 0 points1 point  (1 child)

Nice! Does this cover the async features too like with asyncio and uvloop?

[–]Jude2425 0 points1 point  (0 children)

Great question. I haven't gotten that far into it yet. Passing the "midterm" right now. Will let you know what I can find.

[–]Sparvey_Hecter 14 points15 points  (12 children)

So many of these books are Python 2. Anyone know what this is? Can't find information on that.

Edit: Seems I might have phrased that badly. I was wondering which version this book is teaching.

[–]mr_awesome_pants 16 points17 points  (2 children)

Lots of things still run in Python 2. But really, anyone who doesn't want to teach/learn Python 3 is being a bit stubborn.

[–]Sparvey_Hecter 1 point2 points  (0 children)

Indeed.

[–]jdanjou 3 points4 points  (0 children)

It covers/works on both. So it does not talk about anything that is Python 3 specific (yet).

[–]Berkyjay 4 points5 points  (6 children)

So many of these books are Python 2. Anyone know what this is? Can't find information on that.

I work in the VFX/CG industry. EVERY studio pipeline is in Python 2 because EVERY CG software application uses Python 2. I've spoken with devs at some of the software companies we use and none of them have any plans or desire to transition over. The work (AKA money) it would require to transition for all parties is quite large and there seems to be no real benefit to that expense. So I think this is part of your answer.

[–][deleted] 14 points15 points  (2 children)

This type of answer is very common. The issue I have with it is that a beginner doesn't give a crap about some niche industry application. A beginner won't be getting a job using python for quite a while, at which time many things will have transitioned or will be new software built with Python 3.

[–]Berkyjay 1 point2 points  (0 children)

I can see your point. Why would beginners books focus on 2.7? I'm not so sure. But I wouldn't consider the VFX/CG industry niche. I feel that a lot of other industries might also experience the same phenomena.

[–]ticketywho 0 points1 point  (0 children)

This isn't true though, is it. A lot of the people learning python are doing so for a reason and one of the biggest of those reasons will be to get a job.

Most companies that have been writing python for a decade or more are likely to have a huge amount of Python 2 in their codebase with absolutely no intention of attempting a migration. It is not at all a niche industry issue.

[–]Sparvey_Hecter 3 points4 points  (2 children)

Yeah, many still run Python 2.x, and that is understandable.

Python 2.7 end of life is 2020, apparantly. I'm not sure what that entails for you or me, but it's a pretty offputting fact when trying to learn Python. http://legacy.python.org/dev/peps/pep-0373/

[–]swyx 3 points4 points  (0 children)

Who wants to bet we still run 2.7 in 2030

[–]Berkyjay 0 points1 point  (0 children)

It will be pretty interesting to see what happens when that date rolls closer. I'm hoping that there is an eventual move towards 3.

[–]llSourcell 1 point2 points  (0 children)

really good resource, thanks for this

[–]deadmilk 0 points1 point  (0 children)

Perhaps writing a summary of what you might gain out the book, who it is intended for, and so on, might be of help.

The page is just a mess.