Learning Python the hard way

I spent all of last week learning Python using Learn Python the Hard Way (LPTHW) written by Zed Shaw.

The book is targeted mainly towards people who have never programmed before, but that should not prevent experienced software developers from using it to learn Python.

I spent all of March learning Python using Mark Lutz’s Learning Python. After finishing about 20 chapters, I was exhausted. I have never programmed in a dynamic language before, well, I have programmed in JavaScript, but let’s face it, is that really a programming language? 🙂

Working through Learning Python was exhausting because it my first look at Python, but also mostly because the book is an in-depth reference for Python, which meant that every single statement and concept had a lot of text around it explaining why or how it worked.

Now this is good because you definitely need to know how stuff works, but I was looking to learn just enough of the language to write small useful programs and was willing to dive in and learn more as I went along.

I picked up LPTHW last weekend. It was my second pass at learning Python. A few exercises into it and I was hooked.

Zed’s teaching style is brilliant. Each exercise is short. It has a code snippet that you are to type in and run. You then compare the results of your program with his. There is a short explanation of why or how it worked. An extra credit exercise that builds upon or helps reinforce the concepts that were covered in the exercise.

Because the exercises are simple and short, you can get through them fairly quickly. This helps keep up interest because you get the feeling of being able to progress quickly.

This style of teaching is so effective that after finishing a few exercises, I was able to build a neat tool (for work) that parsed XML and wrote its output to a text file.

The program is very primitive; I do not use any xml library, and instead, read the xml data from the file while going each line looking for a tag. When I find it, I pull out a part of that line by using the substring method.

LPTHW teaches you Python by showing some cool ways in which to use the language. For example, exercise 41 shows you how to store function references in dictionaries and then use that to build a simple finite state machine.

I now find myself building simple python programs for fun.

I wish more books were written using the LPTHW style. See with LPTHW, the author teaches the language using simple and fun examples. These keep the reader interested which leads them to experiment with the language by writing their own programs.

Most importantly, LPTHW helped me re-discover the joy of programming

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s