armchair dot tech
Learning Python | HOME | ABOUT | TAGS

January 3, 2011 | TAGS:

I am reasonably familiar with Perl and PHP languages.  Recently though, I have taken it upon myself to learn Python.  I’ve played with Python a few times, and it seems to be very powerful with lots of useful functionality under the hood.

For some basic practice, I recommend Learn Python The Hard Way, which is free book by a reputable Python author, Zed Shaw.  He makes the book itself available for free as a PDF download or you can purchase it directly.  The book walks you through a number of examples, each one building upon what you learned in the previous exercise.  You are required to enter each exercise in by hand.  This uses the principle that if you learn better by writing things down, you’ll learn better by typing it in.  Copying and pasting completely bypasses that manual entry learning process, so if you want to learn, I suggest you follow Shaw’s instructions.  I found the book rather insightful, but I often felt that certain aspects were not being properly explained to me.  To be fair, I’m only up to exercise 15 in a 52 exercise book.

However, I also came across another way to learn Python.  Google has had instructor Nick Parlante teach Python in a classroom setting.  The class was video taped and put online along with the associated learning aids (primarily a group of python files).  The class was taught in 7 segments over 2 days.  So if you go to the class website, you can download the learning aids, and then follow along with the lecture videos. 

I like this method better than following the static book.  Since it was taught in an interactive classroom, it goes at a pace where you can keep up with it from your own computer.  Also, students in the class were able to ask questions, which allows the information to be represented in a different way.  Finally, at the end of each segment, there are some sample files you can open up in your editor.  Each file has a skeleton template.  In comments, it tells you what a segment is supposed to do, and you have to implement it in code based on what you learned while watching the video.  The sample file also includes some bare bones “unit tests” that call your functions, passing it input data and comparing it to an expected output.  These unit tests will show what they received from your function and what they expected.  If the two matched, you have succeeded. 

I like these practice samples mainly because it immediately forces you to apply the knowledge you learned.  You do have to think about it and do some back and forth troubleshooting on your own code.  Since they provided the unit tests, you can get instant feedback on if you’re doing it correctly or not.

If you want to learn Python and can dedicate an hour on any given day to it, I recommend the Google course.  If you want to go in smaller 10-20 minute blocks, try using Learn Python The Hard Way.  Of course, you can pause the videos and come back to them, but I think it’s much better to go through the entire video, following along on your own system as you go.