Looks like this is an instance method on a class, since it takes "self" as the first parameter. But judging by how you are calling these methods from each other, it looks like perhaps you intend for this example to show these as methods at the root of a module? I see at least one place below (line 134) that uses self without having it as an argument. So either way, a few tweaks are needed to make this code valid.