Python on the Raspberry Pi

Over the Christmas break I thought I’d brush up on Python, as I’ve not used it  for literally years and I’ve all but forgotten the vast majority of what I knew. Give the fact that I’d mostly be using it on the Raspberry Pi I decided to pick up a little book on Kindle that ties the two together: Programming the Raspberry Pi: Getting started with Python. When i say little, I really mean it, I burned through it in no time. Although it’s covering the basics I definitely got the feel that it was a book for people who already program, it didn’t hang around on a lot of points, it did an introduction to an area of the language, an example, and moved on reasonably promptly. Nice. I like.

Anyway, I thought I’d make a start on coding up the weather/alarm clock gadget I mentioned a short while back as a way to get used to Python once again. I’ve been grabbing the rss feed from the Yahoo Weather API and sorting through the interesting elements therein.

It's not exactly rocket science, but it works.

It’s not exactly rocket science, but it works.

I grab the weather code from the XML which in turn I use to grab the textual version of the weather. I also store the code along with a “type” of weather. The “type” is where I’ve grouped different weather codes into some sensible more generic groupings: rain, snow, wind, clear and the like.  I’ll use this for displaying the right icon on the little weather gadget display. I’m also getting the temperature high/low data too, I’ll no doubt end up grabbing wind details etc too, anything worthwhile to display on the screen.

Python really did make this stupidly easy to do as well, I might have to rescind my past vocal dislike for the language (this all works just fine on the Raspberry Pi too even though the above screenshot is from my iMac).


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s