Backtracking a bit: Getting comfortable with your code

16Sep08

So a student, Mackenzie Morgan, asked a question on her Ubuntu Linux Tips & Tricks blog that made me think of this blog. In her post, she asks for advice on teaching Python to an 8 year old. Read the comments, there are some interesting tidbits in there.

Now, I’m not equating your intellectual capacity to that of an 8-year-old, dear reader. Far from it, though research seems to suggest children have a high propensity for learning languages. Guess how I learned to code? Back in middle school, I picked up C for Dummies, an introductory book for the C programming language. I was embarrased about it then, but I learned a hell of a lot from that book. Then I went on to buy C for Dummies Volume Two. The point is, everyone needs to start somewhere.

Anyway, in that vein, I want to backtrack a bit and give a bit more background and a few resources. I’m going to focus on Python here, partly because of Morgan’s post and partly because I think it’s a wonderful way to code.

To start, you need a plain-text editor. A lot of people start with Notepad because it’s included with Windows. I use MacVim or vim for all of my work because I’m addicted to its keybindings and the productivity I gain by being able to seamlessly give commands to my editor. For example:

  • Delete the next four lines: <ESC>d4j
  • Indent the previous 6 lines: <ESC>>6k

I digress though, programmers can fight endless battles over their editors. For someone newly starting out, I’m going to recommend Dr. Python as an editor. It looks like a very simple way to begin working with the language. It also has the advantage of being more of an integrated development environment than something like notepad, meaning it can handle multiple files and run your code directly from the editor itself. If you’re on Linux, my favorite IDE is a little-known project called PIDA.

Now then, some resources on learning the syntax and flow of the language. Morgan mentions a freely-available PDF called Snake Wrangling for Kids. Like I said before, don’t be put off by the name. I downloaded both the Windows and Mac versions, and they’re excellent resources on getting up and running with Python. I suggest skimming it, at the least. Fair warning: it mentions a turtle module there that only comes with a version of Python installed with Tkinter support.

For a little more advanced study, Dave Stanton mentioned a book in my comments called A Byte of Python. Cute name aside, it seems like a fairly comprehensive tutorial to get you up to speed on some of the cooler things Python can do, and is definitely geared more toward adults who seriously want to learn.

Once you’ve got yourself a bit more situated with the language and an editor, you’ll come back with a newfound understanding of how scripting works, and especially some of the code we’ll get into.

Edit: I just found some tips on how to get PIDA working on Windows (via Google’s cache). It’s also available for Mac OSX from MacPorts, but last I checked the code was broken by one line in a source code file…I submitted a ticket, but haven’t gotten around to supplying the patch yet.

Advertisements


No Responses Yet to “Backtracking a bit: Getting comfortable with your code”

  1. Leave a Comment

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


%d bloggers like this: