After reading on several occasions about how Python can be used to create scripts that relate something in a computer to the physical world (like CNC machining or Light painting), I thought this would be a good language to learn. After a quick search for “learn Python,” the second result was a book entitled Learn Python the Hard way, by Zed A Shaw. For some reason this seemingly contrarian title appealed to me, or maybe it was the fact that you can simply jump into reading the lessons right away since it’s all available online.
For someone like me that learns best by doing and figuring things out, this book seemed like an ideal learning path. It gives examples for each of the lessons and asks you to type them in verbatim (At least in the early lessons, it may change later). Some explanation is generally given, but it can be incomplete at times, asking you to have faith and continue with the exercises even if they don’t seem entirely clear. My tendency is to try to figure out what is going on with or without the explanation, and I think the point of the book is to teach in this way.
I’ve worked through 4 lessons so far, and read ahead to beyond “chapter 20” on the Internet. Everything is laid out well online, but if you want to buy it, it’s available for $2.99 in electronic format or $15.99 for a softcover. Not too bad for a textbook, even if I suspect it’s actually fairly short in written form. I keep thinking that maybe I’ll buy one of the online versions if I end up leaning, just to support the guy. On the other hand, I am hyping his book here, so that’s got to be worth something…
Regardless of whether I decide to buy a pay version, I’m really looking forward to the day when I’ll be able to convert a portrait into a drilling pattern for my CNC router, or make some sort of developments for light painting that I hadn’t thought of before (Here’s an article about some light painting I did with my router). Possibly some sort of real-world interface using an Arduino or the parallel port would be possible. Of course, automating some tasks, such as downloading certain files from the internet automatically, or generating ANSI art should be within my reach. I plan to update this blog as I work though these lessons. Hopefully, I’ll be doing some useful stuff with it before too long!
So in the mean time, check out these interesting real-world examples of physical stuff that’s been done using the Python scripting language:
- A simple light bar using an Arduino to power it and Python to break an image into manageable bits.
- Some G-code generators written in Python. I haven’t tried any of these lately, although I think I attempted to use Dxf2gcode at one time with less-than-stellar results. This could be my fault, but CAMBam seems to work quite well (see my review)
- Automatically display tweets using Python to do a certain action on your computer or in the real world. In this case, it’s a laser pointer and speakers, but it could be anything really.
- Here’s a Reddit post about “What was your most clever use of a Python script in Real life.” I certainly haven’t read them all, but I’m sure there is some inspiration there.
Or better yet, just poke around on this site for several hours, or subscribe to my Twitter feed and see what’s going on.