The Clever Monkey

Learning Python Like a Five Year Old

I’ve been putting off learning Python for a few years now. In some double irony, someone I met on an IRC channel dedicated to Perl is a big fan, and has been prodding me to learn it for nearly as many years.

Recently, though, someone got my 5-year old daughter a classic Spirograph toy for her birthday, and she loves it. It got me to thinking that programming a version of Spirograph might be a neat project, and that led to me to old-school Logo turtle graphics, which led me to an O’Reilly webcast based on the book Teach Your Kids to Code. All roads lead to O’Reilly, I suppose.

I then realized that I’d be reinventing the wheel writing such an application, especially when there is a perfectly good Python turtle graphics library to leverage, and entire books on the subject.

So, we (my daughter and I) are working our way through the aforementioned Teach Your Kids to Code book, making little changes to colours and rules and so on. It’s fun!

This has had two results so far, that I have noticed:

  • I am actually learning Python, both how to code like a Python coder and also how to make Python go on OS X and Linux. (In fact, the former was a real challenge, as OS X already has Python 2 installed, and installing Python 3 such that Tcl/Tk and idle3 was layed down properly was a bit of a chore.)
  • My daughter now asks, out of the blue and in public, “daddy, can we do some Python hacking?”, which is a geeky parenting win.

Up to now, the concept of coding has been a bit opaque to her, given that the intersection of code and fun she has been exposed to has been the rather tweaky NQC programs I’ve written for our LEGO robot projects. (Or watching me hack C++ for my cash money.) Which is to say, not very much exposure at all.

So, once I write this, we are back to ch. 2 of the book, exploring more of the ways we can make Python draw nice pictures. Maybe I’ll capture some of the winners and post them here.