Sunday, January 6, 2013

Learning Some Python

I was bored last night and for some reason the site Learn Python The Hard Way was open on my laptop. I think I'd found it a while ago, and like most things I find on the net, I thought "this looks interesting. I look at it later and maybe learn some stuff!", pinned the tab and then forgot about it. Last night I was just bored enough to try the first few exercises. Next thing I know, I'm at exercise 32, and well on my way to having a working knowledge of Python!

Also, I managed to finally get my ass on my rowing erg to finally do my first workout of the new year (got to get in shape for naked man festival) and since my body is basically fucked at the moment, I only did 2000m and it took a whopping 7 minutes 45 seconds. Still, I've got time to improve.

So what do rowing and Python have in common? Well, Concept 2, the company that made the erg has logging software that allows you to record your time and lots and lots of other stats such as the force you are applying each stroke, your speed throughout the entire workout etc. Unfortunately, this software is only available for Windows. I have a laptop with Windows XP on it, but it's depressing having to fire up XP just to log some stats, which might explain why I've only ever done it once and completely forgotten all my Concept 2 site login details...

I Googled to see if I could find any software for Linux, but I didn't have much luck. However, I did find this thread on the Concept 2 forums, containing a link to a utility that makes it possible to access data from the erg via the standard USB connection using Python. OMG! New mini project! As if I don't have enough stupid things to distract me from actually finishing any one thing, now I have a new project, and a bit more motivation to keep up with the erg training.

So the past hour or two I've been just playing around getting PyRow and the required USB to Python interface set up using pyusb, and testing it out to make sure it works with my erg. So far it's all good!

Since I was looking at QT5 recently, I am thinking I might see if QT and Python are a good match and try and make a simple logging application for recording my workouts. WxPython (very tasteful site) would be another option worth investigating for making a GUI with graphs and stuff.

By the way, if you want to learn some Python, I can recommend Learn Python The Hard Way. If you have any programming experience whatsoever you should breeze quickly through the exercises, and if you have none, then you are the target audience and it should be a perfect tutorial to get started with. I was also reading through the Python chapter in the recently released Raspberry Pi Education Manual. This manual deals specifically with programming in Python on a Raspberry Pi using IDLE (whatever the fuck that is... The LPTHW guy is constantly saying "Don't use IDLE"), and is aimed at children with little to no programming experience, but it seemed well written and had some entertaining projects such as a simple ski-free style game using PyGame, a simple web server and a section on using the GPIO interface to make real world objects do stuff.

No comments:

Post a Comment