Buy us a beer!

A python takes me slithering down many a rabbit’s hole

A long time ago, in a company far, far away, I wrote some gawk. That”s geek talk for some code written in a UNIX shell that uses an extension of the ‘awk’ tool. There was great rejoicing amongst the software team as tasks that once had to be done manually were now automated. I eventually moved out of that area and into the world of object-oriented C++ coding and had a good run of a career on that (taking me around Canada and the US and then to the UK).

Then, I met a wonderful woman who knew Matlab and soon we were married (there were other reasons). Matlab as some will know is a wonderful tool for processing, calculating, and plotting mathematical formula applied to data. The tool is script driven – no need to writing complicated C++ code for every little step along the way.

Slithering Snake!

Now, I’ve begun my transition from C++ into Python, a powerful, object-oriented scripting language not unlike Matlab in the way it works (so I’m told).  I’m catching the wave of version 3.4 whilst many programs are transitioning from the older, popular, but incompatible, version 2.7. That’s geek talk for you got to start somewhere and it might as well be with the latest.

Installing Python on my Windows 7 PC was pretty straight-forward. Along the way last week colleagues pointed me to a useful interactive editor called Spyder that displays code with helpful highlighting, documentation, and analysis of the variables used in the code…and points out where I’ve gone wrong when I try to run the script!

Flashbacks!

That's my dad seated at work in front of some electronics equipment at his work. A decade after this photo, it was me sitting in front of an Apple ][+ writing programmes.

That’s my dad seated at work in front of some electronics equipment. A decade after this photo, I was sitting in front of an Apple ][+ writing programmes in Applesoft BASIC.

I have had flashbacks to my teenager days in Whitby, Ontario sitting in front of my newly bought Apple ][+ learning Applesoft BASIC. I learned to code by hand typing in pages of code printed in Nibble magazine — this is long before websites existed, and even before my dad had built me my first 300 baud acoustic coupled modem!

I’m doing the same now albeit with a lot more ease: instead of a magazine there is The Internet. And there is YouTube for tutorial videos. I find that,  just like in my teenager years, typing in code forces me to think about each line, each function, each variable and opens up thinking to how a program can be extended to do things slightly differently, accomplishing slightly different things – things I need getting done.

What got me hooked from the start on Python was David Beazley‘s tutorial video from a conference: Learn Python Through Public Data Hacking.

Through the course of his presentation, he showed how to recover a suitcase forgotten on-board a City of Chicago bus: He challenged his students (and me watching it!) to create a Python program that queries the city’s live bus information to find out when a particular bus is within 1/2 mile of his office as it returned back along its route.

Rabbit Holes

With that introduction to the language, I started branching out to learning something more directly applicable to my work: controlling our equipment through a VISA connection.

As I am finding out each day, the answer to most things in Python is: there is a library for helping you to do that.

Each library you import into a script opens up a whole rabbit’s hole’s worth of new features and learning. Some holes are shallow but some can be quite deep!

No doubt each import will lead to another import which means slithering the Python snake down another rabbit hole.

Just now, I’m learning how to use the PyVisa library, which let’s my scripts query and command industrial equipment.

It may not be as flashy as David Beazley playing with whirring knives, but it’s a start.

 

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>