Looks like there is an indentation problem here.  Could you try running pep8 on this?