« Back to home

Scope: Not Just Mouthwash

I’m teaching a Python class which acts as an introduction to programming, for most of the students there. This is an awesome experience - for me personally because I enjoy this, and for my resume. I hope to do this full-time someday, but today I’ve just got 3 sections of the same class. We’re doing a lot of cool things that I should write about some other time - one of them is using a free, open source textbook called, Runestone - How to Think Like a Computer Scientist.…

Read more »

Syntax Errors

Syntax Errors in Python are great. Here’s one: File "asdf.py", line 2 print("Result is: {}".format(result)) ^ SyntaxError: invalid syntax result = ((5 * 10) + 15 print("Result is: {}".format(result)) Two lines of code… Syntax error on the print line, evidently. But where? That line looks so simple and correct! And pointing directly at the t? Well - it’s not really on the print line. Folks who have done any amount of programming will look at the preceeding line fairly quickly and notice the missing parenthesis.…

Read more »

RasPi Flow Meter In A Pinch - Part 2

META: Part 1 describes the problem I’m trying to solve here. I need a way to monitor water flow through my water filter over several days, and I don’t want to sit and watch it. So - I took a Raspberry Pi I’ve got and a little Python and hacked a solution together. The basic idea was that I’d position a plastic cup below the output stream of the waste water, I’d put two wires into the cup, I’d put a voltage on one wire and attempt to see the voltage on the other.…

Read more »

Python's super()

I’ve been writing a lot of Python lately, and there are some things I love about it, some things I’m uncomfortable with, but nothing I hate. The super() builtin function makes life a lot easier when you’re using Python for object oriented code and have some inheritance going on. This blog post describes the best way I’ve seen it used so far. First of all, in Python3 you no longer need to write “super(CurrentClass, self).…

Read more »