Support Python 3 using six

I've added a comment to the code. Basically, in Python 2, functions and methods are two different things, but in Python 3, they are the same. Weirdly enough, `inspect.ismethod` actually doesn't work to find methods in a class, and you *have* to use `inspect.isfunction`.