Python 2 vs. Python 3: Which LPTHW book should I get?

New visitors to Learn Python the Hard Way may be confused about whether they should read the Python 2 version or the Python 3 version of your book. What guidance can you provide to users with differing programming abilities?

4 Likes

I break it down like this:

If you just want to learn to code then it doesnā€™t matter. Pick whichever one is easiest to install.

  • If you have a Mac then you already have Python 2 installed, so the Python 2 book is fine.
  • If youā€™re on Windows then go with the Python 3 book as itā€™s done entirely on a Windows 10 computer so itā€™ll work great. The Python 3 book supports all three (Windows, MacOS, and Linux), but I made extra sure it worked on Windows.

If you want to get into Data Science, then Python 3 is used there, so get the Python 3 book.

Thanks for the question.

4 Likes

Theyā€™ve said theyā€™ll discontinue support many times and it never happens. Learn the python that you have.

1 Like

I purchased Python 2 long time agoā€¦ and very recently just got LMP3THW but the part that I am interested the most is DB which is not ready yet.

I wonder if after those purchase we could get some sort of super great loyalty discount and maybe I can get P3 as part of more practicing? Thatā€™ll be niceā€¦

Actually itā€™ll be very nice if PYTHON 2 course (for those old timers here) can tell DEPRACATED in the content.

An example of this would be the ā€˜formmaterā€™ part of printing in P2 since is now depracated in P3. Thatā€™ll be at least helpful for old of us with access to old content here.

Rather than doing that I just wrote a Python 3 book. Despite what Python people say, there is still plenty of need for Python 2.

2 Likes

I think itā€™s better to Learn python 3. OK, sure if you have Python 2 only learn it. But Python 3 has continued to develop as a language, with more features being added that improve the language. I think the weight of the python community has now tilted towards Python 3. Most of the interesting talks online are written around Python 3. I recommend Python 3. I donā€™t see why Iā€™d use 2 any more. Well, OK, thereā€™s stuff that only available in Python 2 because those things arenā€™t used that much, and are too hard to port. If you need to use Python 2, then do. But, if your 50/50, Iā€™d go with Python 3 like most of the community.

I checked out both books, and I honestlyā€¦ like the formatting of python 3 a lot better.

Plus a lot of my friends who are in the tech industry gear towards python 3, and it makes it a lot easier to read a lot of code that is on github.

just my two cents.

1 Like

Nice,ā€¦ Iā€™ve been away for a long time and I think is a great idea that @zedshaw come up with this forum idea which is an incentive to ā€˜keep on learningā€™ since I donā€™t feel we are no longer alone.

Anywayā€¦ I know that the importance of P2 is ā€˜backward compatibilityā€™ but looking forward (since Iā€™m not professionaly active on python at all) Iā€™m getting all around P3.

Just sharing my thoughts on thisā€¦

1 Like

I havenā€™t tried python three formating, but not overly fussed, yes you can achieve things in two line that might take you three, however readability is reduced, certain amount of verbose is needed. Itā€™s like going to a fine restaurant and ending up in a pool hall. Iā€™m really only new so donā€™t take my word for being ā€œthe best optionā€.

But if you like music or poetry, than python 2 is like these python 3 is the daily news, boring even though it is dramatic.

2 Likes

I put a lot of work into the updating the Python 3 book so that itā€™s matching more whatā€™s going on in Python these days, but without some of the dumber stuff I see them doing.

2 Likes

A huge reason why I purchased your book!

My friends have critiques (of course), but I find your style particularly captivating, and it allowed me to actually write an openfile.py program that impressed my friends.

They were likeā€¦ F STRINGS!!! YOU GOT F STRINGS EVERYWHERE MAN :slight_smile:

1 Like

@ricarod What is DB? I am hours old in the coding world :stuck_out_tongue:

Data base.

I was referring to the part of coding that is not about making a program that makes calculation (like a function that return the area of a rectangle) but the ones that store records persistently like clients information, billing, etc.

You can then take that, put it on a web framework and have something to offer as a service

Eh I was wrong. Coding style doesnā€™t change much.

https://docs.python.org/3.0/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit

I find that so bizarre. So, the Python 3 proponents will tell you to use Python 3 because itā€™s the future, but if you use the most recent version of Python and use the best feature of it (f-strings rock), then ohhhh nooooo thatā€™s tooo much future good sir! We mean Python 3.5, but definitely because itā€™s the future, just not so much future as 3.6, because thatā€™s so much future.

2 Likes

Dare I ask ā€¦ Wtf are F Strings?

The Python 3 version of formatting strings. In Python 2 it was

print("{} bar".format("foo"))

Output: foo bar

In Python 3 you do

var = foo
print(f"{var} bar")

Output: foo bar

1 Like

A fine comprehensive overview of all of Pythons formatting options you can find here: https://pyformat.info/

For other cool links on Python topics you can see my Library in the Python category: My Python Library

1 Like