12 ms·
Learn Python The Hard Way: a new book by Zed Shaw
- Tichy 17y agoWhoa, that was quick.
- sync 17y agoInteresting captcha system on the login page: http://learnpythonthehardway.com/login http://learnpythonthehardway.com/login
- mdg 17y agoThat is just how fossil rolls.
- wmf 17y agoThat ASCII art CAPTCHA looks geeky, but it should be trivial to crack and is thus worthless if very many sites use it.
- zedshaw 17y agoOr, just hit the little javascript button at the bottom that fills it in. It's only there to keep bots out. It's not all that secure.
- codexon 17y agoYou mean script kiddie scanners. document.getElementById('p').value='5544e312' This isn't going to stop anyone who knows urllib.
- zedshaw 17y agoHave you tried using urlib and urllib2? I think that alone prevents anyone from getting to the site. :-) Seriously though, I'm going for simple and if there's a problem then I'll lock it down more completely.
- codexon 17y agoI have written multiple crawlers for sites like facebook with them. import urllib2;urllib2.urlopen("http://learnpythonthehardway.com/login http://learnpythonthehardway.com/login).read() Since you only want basic protection, you could avoid the visual captcha all together and have the "Fill out captcha" button auto-submit.
- vinhboy 17y agoBe sure to read the end.
- ube 17y agoThe message at the end is quite good. It is the same message he gave at the http://blog.cusec.net/2009/01/05/zed-shaw-the-acl-is-dead-cusec-2008/ http://blog.cusec.net/2009/01/05/zed-shaw-the-acl-is-dead-cu... talk. I discovered Zed through the rant against Ruby's community (I had done a google search about ruby disadvantages or something like that and his post came up). He's grown up quite a bit.
- zedshaw 17y agoNo, not really. :-)
- ube 17y agoWell...I suppose my criteria is weak since I couldn't find your Judas Priest image on your site...so I assumed you've grown up (a little) :-P
- deleted 17y ago[deleted]
- zedshaw 17y agoOhhhhh, I forgot some people equate "serious" with "grown up". Sorry, yeah, I'm totally grown up now that I took that one joke down. :-)
- gte910h 17y agoStill very incomplete. Goes from exercise 10 (by which point they've not done if statements) to exercise 27 (where they start learning about AND OR etc. Tone/diction/sentence structure is a bit patronizing. I think Shaw was going for more basic than is required for most intelligent adults.
- billjings 17y agoHave you never worked with someone and had the thought go through your head, "Sure, this person's intelligent... but can they write code?" I'm not sure this book is a solution to that problem, but it certainly has a strong opinion.
- rbanffy 17y agoA programming book has as much of a chance of turning you into a programmer than swimming classes of turning you into a fish.
- hockeybias 17y agoI fail to concur.
- harpastum 17y agoI disagree with that analogy. It's true that some people just aren't ever going to be programmers, and no number of books will help that. On the other hand, some people have all of the correct mental attitudes, they just haven't been introduced to programming before. I think a much more reasonable analogy is something like playing the harp. Most people see little point in learning, and many of those that try it won't have the aptitude/interest to actually become adept, but there are a few that will become masters.
- rbanffy 17y ago> some people have all of the correct mental attitudes, they just haven't been introduced to programming before. They already are programmers. They just don't know it yet
- jmm 17y agoHoly... The output of this guy is as awesome as it is diverse. Way to go, Zed.
- gcv 17y agoA nice quote from the last chapter: Programming as a profession is only moderately interesting. It can be a good job, but if you want to make about the same money and be happier you could actually just go run a fast food joint. You are much better off using code as your secret weapon in another profession. Well said, Zed. Very well said indeed.
- jrockway 17y agoThis is very true -- if you're bad at it.
- jerf 17y agoIf you finish this book in its intended role, you will be bad at programming. That's an upgrade from the "completely unable to program" from before you started, but still, you'll be bad. Instead of reading it as discouragement to become good at programming, I'd read it as encouragement that it can be used in the other things you are interested in. You don't have to be "a programmer". It's an important point.
- zedshaw 17y agoActually, you're right, but I wouldn't say "bad", I would say, you're ready to learn programming. Kind of like this gets you your programming brown belt.
- gcheong 17y agoCurious to know what other profession you might be considering going into where you can use your programming skills as your secret weapon.
- aaronblohowiak 17y agoAlmost every profession, actually.
- deleted 17y ago[deleted]
- sandofsky 17y agoFrom what I've read, Zed's goal is not to be exhaustive training for an existing professional developer, but a gentle introduction for the non programmer. He's leveraging his experience from taking time off to go to music school. http://sheddingbikes.com/posts/1272132621.html http://sheddingbikes.com/posts/1272132621.html
- zedshaw 17y agoYep, that's correct. It's just a key to open the rusty lock.
- zedshaw 17y agoIt uses printing to teach strings, format chars, escape sequences, variables, and calling functions. Glad to see my sneaky ways are working. :-)
- deleted 17y ago[deleted]
- mturmon 17y agoI think introducing some mystery of programming would be nice. The draft is very linear and predictable. How about a random number generator (linear RNGs are easy to code)? Or a line-by-line chaotic ascii art generator (like Wolfram's CA's)? Or, some other way to combine some of the string stuff with the arithmetic stuff. Also, I think python's + and * string operators are far cooler than the string escape sequences. A 6th or 7th grader would have mastered + and * for numbers, and the extension to strings might be interesting to them. Think of how cool some of the examples in SICP are as an inspiration. Simple, powerful, surprising. Not just type this, get that. The last page is nice, and insightful about the expanding future for using programming to advance another discipline. The bitterness at the end ("go to hell") was an off-taste.
- blehn 17y agoI like the idea of this -- any chance for a Ruby spin-off?
- sigzero 17y agoMaybe by someone else? I think Zed is done with the Ruby camp. Although only he can really answer that.
- Adaptive 17y agoIf Zed started off life as a slightly loose cannon coding rock star, I believe we've seen him evolve into something much more important with greater staying power. Here's hoping he stays excited and engaged in the Python community.
- zedshaw 17y agoI was never a coding rock star. That's an image other projected on me along with "he's a Ruby guy", "he's a Python guy", "he only codes scripting languages", and many other bizarre myths. But hey, like David Lee Roth said, "Who am I to fuck up a good myth?"
- aaronblohowiak 17y agoI think the ZSMFA thing was hilarious, but it went over most people's heads (sadly.) Watching your vim-fu at the first RoR conf (which I don't expect you to remember,) I still long for a series of vim screencasts from you, going into things like custom vim scripts and how you integrate it into your workflow.
- n8agrin 17y agoThis looks like a good start for what may become a great resource. Like others have noted, the ending is well worth reading, pity it had to arise from such vitriol.
- abyssknight 17y agoI said this on Twitter directly to Zed, but it bears mentioning here. This is a sweet introduction to both programming and Python. I started playing with Python a couple weeks ago and wrote a few small applications. One of my pythonista friends looked over my code and noted that I could have used string formatting instead of concatenating everything. None of the books and tutorials I'd skimmed mentioned the print formatting but this book explained it perfectly. Best of all, its succinct. I'm sure there will be a ton of new exercises added to the book, and more topics to come, but this is a great start. Thanks Zed!
- zedshaw 17y agoGlad it's working for you. As I work on the book, let me know if any exercise isn't making sense. Many times if that's happening there's something you're missing I need to include.
- elblanco 17y agoI'll be getting some free time in about 3 weeks and have been interested in picking up my python education again (after a very long hiatus). I've written some non-toy language tools in it and was impressed with the language, but the existing books I was learning from were too hard to keep referring back to and I've long since forgotten even basic syntax. I'm following this book with a great deal of interest and plan on working through it completely. I'll let you know if I get any hangups.
- simplegeek 17y agoThis is awesome. I love this guy, really. Zed, I'm interested in knowing how did you evolve as a programmer? Do you've a degree in Computer Science? If no, how did you go about learning all the stuff that you know today? Totally OK, if you choose not to answer this one ;) Non-native speaker, so sorry for bad English.
- zedshaw 17y agoI have a business degree, MIS. CS was boring with no depth, but business let me study a ton of random things and focus on people and computing. Other than that, I don't drink, so that gives me lots of extra money and free time. Like I just bought another guitar. Woot! G&L Comanche. Can't wait.
- zedisatwat 17y agoWhat the eff has that to do with the fact that you don't understand what it means to teach?
- zedisatwat 17y agoAre you familiar with the concept of devolving?
- j_baker 17y agoThe restrictions on proposed exercises seem a bit extreme: http://learnpythonthehardway.com/wiki?name=Proposed+Exercises http://learnpythonthehardway.com/wiki?name=Proposed+Exercise... If a beginner can't learn OOP or use projects that span multiple files, are they really ready to learn Python the hard way? Plus, I would disagree with the definition of "complex math". My college discrete math teacher (who was from Mexico) said that he learned everything he was teaching us in elementary school, so I don't think that just because you learned some math in college necessarily makes it complex.
- zedshaw 17y agoWell, they can't quite code Python when they're done with this book. They could then move onto a book that teaches those concepts. And if you think about it, there's no point in learning OOP before you've even learned basic logic, functions, and I/O. That's what I learned first (because there was no OOP when I was learning). Finally, your professor and you are not who this book is meant for. The simple fact you think discrete math is alright for anyone but a CS major is proof of that. Not to be mean, but it is.
- j_baker 17y ago"The simple fact you think discrete math is alright for anyone but a CS major is proof of that." Fair enough, but that doesn't make me wrong. There is a valid case to be made for teaching discrete math to people who aren't CS majors or even in college: http://www.artofproblemsolving.com/Resources/articles.php?page=discretemath http://www.artofproblemsolving.com/Resources/articles.php?pa... In particular, the argument that discrete math is fun is the most compelling. Be honest, what did you enjoy the most: algebra, calculus, or discrete math? I'd argue that if you say algebra or calculus that you're the abnormal one. :-)
- zedshaw 17y agoCalculus by far. I read this "Calculus Made Easy" by Silvanus P. Thompson and it's still to this day my inspiration for explaining complex technical topics to lay people. It's a fantastic book, and even if you know math you must read it if you want to understand how to teach complexity to others.
- mmacaulay 17y agoI've never heard of fossil before. There's a lot of noise around Git and Mercurial these days (I just recently transitioned to Mercurial from SVN), but fossil sounds like an interesting concept - and indeed, once I've got an SCM, the next thing I go looking for is some kind of bug tracking system to integrate it with. Nice!
- sandGorgon 17y agohttp://news.ycombinator.com/item?id=809493 http://news.ycombinator.com/item?id=809493
- tingley 17y agoThis is wonderful. I've "been thinking" forever about trying to write a book to teach children (in particular) how to program in python. But among other problems, I had never come up with an approach that made sense. (That is, one that didn't start with something stupid like "data types".) So, I really like the approach here, and I really like the tone.
- seanc 17y agoAllow me to recommend "Hello World, Computer Programming for Kids" http://www.manning.com/sande/ http://www.manning.com/sande/ Full disclosure, I know the author, and helped out a bit with the book.
- smiler 17y agoThe output of Zed Shaw is unbelievable in terms of stuff he actually gets done and delivers. Maybe he should deliver a few GTD seminars :)
- DannoHung 17y agoHe'd just yell at you until you left the room and started doing something else.
- jonpaul 17y agoSometimes I'm not sure if Zed is a prima donna or just misunderstood. But, one thing is for certain. Zed definitely contributes to his respective communities. He contributes a lot. Probably more than most of us ever will. Thank you Zed for your hard work and contributions.
- Keyframe 17y agoon a related note, has anyone read through Thinking in Python?
- rincewind 17y agoif zed is indeed the anti-why, this will be his non-poignant guide
- Lozzer 17y agoZed's soothing guide to Python?
- Keyframe 17y agoHow is this better than python docs again? Seriously. It's not for beginners, it's not for intermediate, it's not for advanced users in its current form. I remember when I was a kid (cue during the war...) we had to type in sheets of paper in order to play games, learned through modifying them, experimenting like in a sandbox. I don't remember if I saw something similar in the past 15 years or so. It doesn't even have to be a book, it would work as a sandbox type of environment. I think I saw one based on scheme, but I can't remember the name right now.
- zedshaw 17y agoThat's the feel I'm trying to capture, but in a more structured way so it's more generally effective. I learned that way too. Typed in a game where a Donkey had to dodge cars, all written in BASIC. Reams and reams of paper. Line by line. But, to be honest I also had some original aptitude, so I got lucky that this worked out for me. Expecting other people to just "type in a load of code" probably won't work the same.
- Keyframe 17y agogood luck, you'll need it! I remember that feeling since I typed in all of that code that I was a master of it, so I inherently started adding stuff into it, which made me go look up how to add stuff into it, pretty simple learning process. Not to mention "debugging" typos.
- ezy 17y agoOne common theme, at least for the programmers growing up in the 80s, was that all the BASICs had graphics support. Like you, I didn't learn logic and control structures to print out tables of numbers, I learned it so I could make an object move on the screen and to draw pretty pictures. I learned all the print capabilities to make a pretty looking layout on the screen and to get some random information "just so". The reason I say this is that I like the idea behind this text, a lot, for people who want to learn from nothing, but I don't think it will hold people's interest for that long. I keep wondering if they'll just burn out if you're doing nothing but printing out the textual results of logic puzzles. I'm not asking for a video game, in fact, I'm not sure exactly what I'm asking for, but there's got to be a way to light a fire in someone's head the same way it lit in mine when I typed in "line 32,32 to 32,64" from the BASIC manual and a red line appeared on the screen... and I realized I could do anything on that screen with the right sequence of commands... anything. (Well, I found out otherwise later... but that's how it felt) (And yeah, I realize getting graphics set up in python sucks for rank beginners... part of the reason I'm not sure exactly what should be done...)
- douglasputnam 17y agoAs a teacher I can attest that it's impossible to find decent programming "text books" for Python, PHP, etc for classroom work. Most of the books you see on the bookshelves at Great Big Book Chain may be great books for programming language autodidacts, but they don't get adopted in courses because they universally lack relevant exercises for newbie students. As a result, instructor's have to create all of the questions and exercises for the course---he/she might as well work without a book. At MIT, the Intro to Programming Course (using Python), doesn't have a textbook because, say the instructors, there are no good textbooks for Python. If Zed can come up with well-paced and instructive questions (Little Schemer-style), he's got a winner. BTW, If you plan to contribute questions to Zed's book, try to put yourself into a newbie state of total ignorant bliss. Remember that the ideas you take for granted and think of as "simple" are completely daunting to beginners. Pacing is everything.
- mikeklaas 17y agoThe <title> element reflects the current page, which is a nice improvement over his other new sites <g>.
- jacoblyles 17y agoThis is awesome, Zed. I would have loved this five years ago, the first time I tried (unsuccessfully) to teach myself programming. I actually tried to learn with emacs and SICP because I took advice from the "wrong" people. The second time I tried to learn programming it was a lot easier because I was in grad school and had people to help me. If you don't have people to help you, then existing materials are very hard to learn from. This book seems perfect for solving that problem.
- zedisatwat 17y agoFive years ago zeds document would have treated you like the x you are.
- samratjp 17y agoThank you zedshaw for doing this. I do hope this will make it to the HN "evergreen" page (if pg ever makes one). It seems like every now and then someone asks how to get started with coding and well now they can.
- XFrequentist 17y agoFrom the final chapter: "Programming as a profession is only moderately interesting... You are much better off using code as your secret weapon in another profession. People who can code in the world of technology companies are a dime a dozen and get no respect. People who can code in biology, medicine, government, sociology, physics, history, and mathematics are respected and can do amazing things to advance those disciplines." Don't know about the programming profession, but the secret weapon bit is true to a degree that might shock many of the readers here. I would even go so far as to say that NOT knowing how to program causes ridiculous waste of resources in other disciplines. Working as an epidemiologist during the H1N1 pandemic, I saw literally dozens of man hours drained on repetitive statistical reporting and database tasks that the average reader here could probably automate in under an hour. There were lots of extremely smart people running around with a ton of important things to do, but since no one (myself included) really knew how to program, what were we to do? I think I was the only one to even have the inkling that we could probably be replaced by a few Excel macros. I don't know this guy's back-story (or why he seems to inspire such antipathy), but this passage got me very excited! I'd already bought into the idea that learning at least the basics of programming would be a good way to improve my general analytic thinking ability (a noble goal, IMHO), but I was being held back by the thought that it was a bit of a frivolous endeavor. This has really inspired me to get started! Secret weapon indeed! Wooo! [EDIT: I see several others have commented on this bit. Sorry to be repetitive!]
- zedshaw 17y agoYep, that's the idea. Writing a book for programmers isn't really that useful. There's plenty of those and adding one more programmer to the tech scene would be like spitting into the Pacific. But, if I can improve every other discipline by making it easier for them to learn to code, and then get them to use code to improve things, then that's a much better goal.
- XFrequentist 17y agoThat sounds like a good goal indeed. Looking forward to reading it!
- 17y ago
- jay_kyburz 17y agoI know Zed was just reacting to dive into python, but if I seriously wanted to help people learning to program I wouldn't write a pdf, I'd make a fun interactive website. The first think Zed asks his readers to do is find the terminal and get a python command prompt up un going. arrg.. The first thing a new programmer should do is something cool and interesting, or useful. Immediate gratification. 10 PRINT "Jay Rocks" 20 GOTO 10
- zedshaw 17y agoI'll have a page on the site they go to for the first exercise, so it's always updated with the latest best starter thing to do. However, the #1 problem all the people I've tested this on have is getting basic gear going. The simple act of just "write, run, fix" is even daunting. The goal of this section is to give them a very simple set of things to do so they can get to just enough working gear to do write, run, fix. That "immediate gratification" just doesn't exist anymore. It existed for BASIC because Microsoft included it for free for years, so no install needed. These days there just isn't something like that out there. The only exception to this would be a Javascript book. But, javascript is such a giant nasty mess it would be hard to teach things like this. Without good error messages, syntax errors, etc. it'd be pointless to teach it.
- steveklabnik 17y ago> These days there just isn't something like that out there. If I could find some time to fix up Shoes and then Hackety, there would be. It's hard when you can't get the library you're building on to compile...
- MicahNance 17y agohttp://www.trypython.org/ http://www.trypython.org/
- deleted 17y ago[deleted]
- madmanslitany 17y agoI have a younger cousin in high school right now who's just starting to show some interest in an engineering career. It could be interesting to try to use this to teach her to program. Tempted to try over the summer and then blog about it. I think she's thinking either computer science or electrical engineering, might be a good way to sway her over to my viewpoint from my father's...
- zedisatwat 17y agohttp://en.wikipedia.org/wiki/Zed_Shaw,ah http://en.wikipedia.org/wiki/Zed_Shaw,ah, ruby, ruby,ruby, rubehh, ahhahh. try jedit: Written in Java, so it runs on Mac OS X, OS/2, Unix, VMS and Windows. Too hard to recommend a 'text editor' for all those stupid peoples. Python from Ruby -- clever. As long as I have zed I have a job.
- bufordtwain 17y agoI like it a lot so far - a very nice start to a book that is very different from the typical beginner book (in a good way).
- c00p3r 17y agoMaybe the case is not that programming became less interesting, but that there are too many (mediocre) programmers.
- Qz 17y agoIf a programmer tells you to use vim or emacs tell them no.
- donaq 17y agoThat was an interesting read. I think Zed has very nicely anticipated many questions a novice programmer might ask while avoiding the trap of trying to spare them the grunt work required to understand the basic concepts a programmer requires.
- tgerhard 17y agoI've just started showing my nine-year-old son how to do simple printing and math in Python (basically Chapters 2 and 3 in LPTHW), and he is pretty stoked about it. This will be a great addition. Not to overburden the discussion regarding the last chapter, but I have to agree with the very last line: "You can code. They cannot. That is pretty damn cool."