You're proceeding without checking for errors, so it's no shock your code fails this way. From your description, it sounds like mymod is NULL, which would be consistent with a failed import. One possible cause of the failed import is that the reverse.py you posted has a syntax error.