top | item 9275357

Learn Python the Hard Way

240 points| colund | 11 years ago |learnpythonthehardway.org

172 comments

order
[+] bluerail|11 years ago|reply
Thank you Zed Shaw.. This is an excellent resource that has helped me to become what I am today.. I started learning Python using this book and he really takes time to ensure the readers understand what they are doing.

It may be too silly for you programmers, but almost every beginner programmers as me would have definitely cam across this resource. This has helped innumberable and I'm sure it will.. Thanks once again.

[+] zedshaw|11 years ago|reply
You're welcome. I honestly write the books for people like you, and thankfully the world of programmers and the world of regular people really doesn't intersect much.
[+] shanecleveland|11 years ago|reply
One of the most important challenges I have undertaken in the past several years.
[+] yitchelle|11 years ago|reply
It is interesting that one of the way Zed advocates for learning is to type, (instead of copy and paste), the code into the computer. That reminds me when I was cutting my teeth at my introduction to computers. I would get computer magazines like Compute! and type in the 100s of lines of code that comes with it. Especially the arcade games listing. I think this method also improve my debugging skills as I was tracking down the error (usually I did not type in the code properly or there was a misprint in the magazine).
[+] jussij|11 years ago|reply
> Zed advocates for learning is to type, (instead of copy and paste)

The copy an paste option is always attractive, as it gives the impression of writing lots code quickly. But I agree with Zed in that it leads to a false premiss of being productive.

Coding is all about typing in code, not copy and pasting code.

It's actually quite hard to type in lots of code without generating compiler errors. But it is quite easy to just copy and paste code without error.

So the copy an paste option leads to a false sense of coding ability.

[+] enobrev|11 years ago|reply
Typing it out definitely helps with muscle memory. Every time I start trying to learn a new language, I make sure to type out all the examples I hunt down while trying to implement something.

Whether it's whitespace, or semi-colons, or brackets. After a couple days of typing everything out, they become second nature and I don't have to worry as much about syntax as I do about thinking in whatever way the language seems to flow.

[+] snlacks|11 years ago|reply
I didn't start with Zed's stuff, but I checked it out when I was interested in Python.

For someone like me, it would have been really fun when I was less experienced. I would have liked the repetitive challenges while I was doing them, because I would have challenged my self to go through them as fast as a I could and gamify it (though it wouldn't have been called gamification back then). It would have got me to memorize things.

His books are different, I appreciate another take on them. I would read and follow along with his books if they fit my needs now. I've recommended him a couple times to people I thought would benefit from that style.

As to his personality, I think most people are jerks sometimes, and not jerks at other times. We all have our issues. :)

Generally, I feel that all the conversations about it much more harmful to the profession than the original instances being discussed.

[+] zedshaw|11 years ago|reply
That's a good assessment of the books, and one I put into the introduction. It's weird because what is great for a beginner with zero knowledge is incredibly painful for someone who's experienced. I think that's the key with my book's success and also why a lot of professional programmers seem to completely dislike it. It's also why I'm very honest and upfront about this right in the beginning.
[+] dsego|11 years ago|reply
If you know anything about programming, skip this book. If you don't know anything about programming, also skip this book. It gives you drills without explaining anything. My SO started learning with this book and I could see the book only caused confusion. She completely misunderstood how functions and function invocation work. And his way of teaching boolean logic is to memorize truth tables, wtf?
[+] brudgers|11 years ago|reply
The pedagogy of Learn Python th Hard Way is called 'Direct Instruction'. It has been successful for teaching the very rudiments of diverse subjects. It falls flat once applied to teaching creative intuition or abstract conceptual reasoning. That's why Learn Python the Hard Way is targeted at beginners.

Page 4 of the Shaw-Hanselman interview transcript discusses direct instruction.

http://s3.amazonaws.com/hanselminutes/hanselminutes_0407.pdf

Out of curiosity did your SO learn Python and if so what resources worked particularly well?

[+] las_cases|11 years ago|reply
> She completely misunderstood how functions and function invocation work.

How can that be? I remember learning about functions such as f(x) = ax + b in the fifth grade if I am not mistaken and learning about functions in programming was extremely natural. I studied programming in high school taken from the very basic and nobody had troubles with how functions worked. It was so math like that it was simply a non-issue. I am really interested to understand what the problem was and how did she figure it out eventually.

> And his way of teaching boolean logic is to memorize truth tables

But isn't Boolean algebra based on exactly that? Isn't this the pillar field covered by the mathematical logic, how can it be wrong?

[+] chucksmash|11 years ago|reply
> And his way of teaching boolean logic is to memorize truth tables, wtf?

That seems like an odd thing to single out. I took an "Intro to Logic" course years before I did any CS courses and truth tables were very much used. I believe that they helped ease students not accustomed to thinking precisely about logical propositions into that mode of thought. Why rely on students' intuitions about ambiguous natural language constructs when we can be explicit and also provide an early lesson on the precision required by machine languages?

[+] mekoka|11 years ago|reply
Ah, anecdotes... my nephew is learning from this book and loves it.
[+] joshuapants|11 years ago|reply
I agree. I suggest the Head First series by O'Reilly. They are much more beginner-friendly and the teaching method is based on research and not some crufty old belief that learning should be "hard."
[+] druml|11 years ago|reply
I have been waiting for the completion of Learn C the Hard Way for a while, BTW.
[+] zedshaw|11 years ago|reply
Me too, man that book has been an epic slog. I've ended up rewriting it like 10 times but finally have a draft off to the publisher for editing. I'm still not totally happy with it, but it's the best I could possibly do.

The latest rewrite emphasizes secure coding and defensive programming practices, algorithms, testing, and how to learn a new programming language, and simply uses C in as safe a way as possible to do that. Hopefully it's effective but I still need to sit with students in IRL classes to test that out better.

[+] VinzO|11 years ago|reply
Same here. I pre-ordered it on amazon back in 2013! I am getting pissed as every few weeks I get an email informing that the released date is postponed again.
[+] koshak|11 years ago|reply
Python 2.5.1

Python 2.6.5

no use of context managers when working with files

no use of format when working with text formatting and output

"Avoid any project that mentions "Python 3""

"Every if-statement must have an else"

no list|dict|generator|set comprehensions.

no idiomatic hints

no gotchas.

Definitely a hard way.

Having learnt wrong leads to hard learning to do right.

[+] cjf4|11 years ago|reply
Having actually used this as a self learning tool, my feelings were mixed. On one hand, I think it's organized and clear. On the other, I found it's drill approach to be ineffective for me.

I think reps are really good for something that uses muscle memory, like shooting 3s or dicing an onion. However, I found for learning programming, I got a lot more mileage out of teaching methods that have set up a solvable problem, point you in the right direction, but leave it to me to create a solution.

[+] ghost91|11 years ago|reply
And still not using python3.X …
[+] volent|11 years ago|reply
"A programmer may try to get you to install Python 3 and learn that. Say, "When all of the Python code on your computer is Python 3, then I'll try to learn it." That should keep them busy for about 10 years. I repeat, do not use Python 3. Python 3 is not used very much, and if you learn Python 2 you can easily learn Python 3 when you need it. If you learn Python 3 then you'll still have to learn Python 2 to get anything done. Just learn Python 2 and ignore people saying Python 3 is the future."

I don't think it is useful for a beginner to start with python3.

[+] zedshaw|11 years ago|reply
I have to serve the student's needs before any in the community, and there's a very practical reason for going with Python2:

The vast majority of code out there is in Py2, so if someone learns Py2 first, they can start coding and doing stuff right now. If they stumble onto a need for Py3 later, then they would have the skill to learn Py3 from the tutorial and other books.

If they learn Py3 first, then immediately they have to learn Py2 because there's simply too much code out there that uses it. This will frustrate beginners as the next thing they need to do after my book is start using Python to make things.

When the situation changes, and not just because the Python leaders say it does, then I'll update the book. Honestly though, I think Go, Rust, Nim, and Clojure have a better chance at widespread adoption than Python3 at this point.

Incidentally, the mistake that the Python3 project made was to not use a virtual machine that could run both 2 and 3 byte code. If I can run tons of languages on my CPU, the JVM, and the .NET CLR, then Python3 could have run both 2 and 3. I predict that to get people on the new version of Python they will have to make Python4 and have it run 2,3 and 4 seamlessly so that it won't matter how much code is out there in any version of the language.

Just my .02 on that topic.

[+] prof_hobart|11 years ago|reply
Is anything? I've recently decided to start learning Python and started with the assumption that Python 3 would self-evidently be the sensible thing to do.

I tried that for about a week before discovering that about 90% of the libraries that I wanted to play with, and 90% of the tutorials and StackOverflow answers that I found were 2.7-specific.

[+] arafa|11 years ago|reply
I went through this whole class when it was linked here a couple of months back and really enjoyed it. I'm a self-taught programmer that needed updates on some modern concepts and a refresher on some other stuff, plus a bit of help with Python syntax. If you're like me (or a beginner) it's great. Thanks Zed.
[+] thebouv|11 years ago|reply
I have no idea who Zed Shaw is. I've always wanted to know more about Python. Might give it an unbiased read through.
[+] Johnny_Brahms|11 years ago|reply
If you want to see some really nice python, look at his "lamson" project. It's really nice.
[+] cdnsteve|11 years ago|reply
Loved the "A Warning for the Smarties" part.
[+] ianamartin|11 years ago|reply
Ummm, I don't understand all the dislike. For someone with my background, this was absolutely perfect. It's one of the very first things I read when I decided I wanted to learn Python. Fast forward several years, and now writing Python code is what I do for a living. I could not be happier.

I was a violinist, and Zed Shaw's way of teaching the basics completely resonated with me.

Thank you, Zed.

[+] dmkmz|11 years ago|reply
Hello Zed. I didn't actually read whole LPTHW, but LCTHW helped me a lot. I recommended LPTHW to some friends of mine, who were interesting in programming but had no experience at all. Few years later and they are doing programming for living. I personally think it's a good source for a newbie to start with. Keep going with your job and thanks.
[+] pknerd|11 years ago|reply
Sorry for being OT but I would request Zedshaw to write next book about Go Language.
[+] napolux|11 years ago|reply
So, is it good or not? :D
[+] dagw|11 years ago|reply
If you're new to programming, it's pretty good. If you're an experienced programmer looking to pick up python, then it is very slow going and takes a while before it gets anywhere interesting.

Basically it should really be called Learn Programming The Hard Way Using Python

[+] omegant|11 years ago|reply
As a raw beginner that tried this book as the first I'll say that it's frustrating to try to learn with it. It explains something pretty well and then suddenly there is a big knowledge jump that you must fill looking at internet (I had to check the python documentation several times to understand what was happening at some examples).

I started looking at other books and found "Learn python programming arcade games with pygame"by Paul Cramel, who is teaching his own book at an university course.

For me it's sooo much clear, taking you step by step through the difficult concepts (hand holding if you wish), that suddenly are not that difficult. It contains lots of simple exercises and questionnaires that make sure that you understand the concepts in the lesson. Each lesson has also it's own Lab, that gives you the specs and making you use the lesson material to code on your own. I find this to be the perfect way to fix the ideas in a practical way. I don´t know enough to create my own exercises' specs being a complete newbie.

Of course making games and moving drawings is hands down much fun than writing command line scripts.

It only has a small problem, you need to install pygame's libraries, which can be a bit difficult in mac. I had to do several tries with snow leopard, Finally I installed the latest Mac OS and it installed without problems.

I'm recommending it to every body who asks me. It's free in his site and the e-book(that I bought) it's inexpensive.

I´m sure LEARN PYTHON THE HARD WAY is and will be useful to a lot of people, and don´t mean to disrespect the author effort in helping people learn programming, but I thought worth giving an alternative in case you are looking for one.

I´m not related in any way to Mr. Cramel, I just happen to find his book very useful.

[+] SpaceInvader|11 years ago|reply
For beginner it's pretty decent. I enjoyed it few years ago (probably that was some older revision).
[+] munchhausen|11 years ago|reply
So I'm scrolling through this comment section, thinking, "Are we ever going to talk about the book or what?".

This thread is proof that programmer types need their share of celebrity gossip as much as anyone :)

"That Zed Shaw. He's abrasive, but is he too abrasive? Tune in to our panel discussion to find out!"

[+] qzcx|11 years ago|reply
Right? I came to the comment section to post something I found funny in the introduction... but I'm afraid people will get offended by it now.

"If you are reading this book and flipping out at every third sentence because you feel I'm insulting your intelligence, then I have three points of advice for you:

1.Stop reading my book. I didn't write it for you. I wrote it for people who don't already know everything.

2.Empty before you fill. You will have a hard time learning from someone with more knowledge if you already know everything.

3.Go learn Lisp. I hear people who know everything really like Lisp."

[+] las_cases|11 years ago|reply
Wow, how come Zed Shaw manages to attract so much hate? I have found his series to be absolutely delightful. Anytime something about him appears on HN I can be sure there will be users with ad hominem attacks like this:

"> is this a joke?

No, just written by Zed Shaw. Honest mistake though."

How about you let go of the hate and embrace some love instead for the work this man has put forth?

LE: For advanced Python you can read his code from the Lamson project. I am sure there are many other coders out there who are just as talented as he is but he takes the time to comment his code and also has a style of clarity so to speak. Thank you Mr. Shaw for your work and thank you to all of the amazing, talented coders out there who gave me confidence and helped me to learn.

[+] Psion7|11 years ago|reply
Why is this at the top of HN? Didn't the 3rd edition come out ages ago? What exactly is new?