Indentation is messed up all across this file. Sometimes it's tabs, sometimes 2 spaces, sometimes 4 spaces, sometimes both tabs and spaces on one line! The PEP8 standard, which happens to be the industry standard, opts for 4 spaces for indentation so please use that: http://legacy.python.org/dev/peps/pep-0008/#indentation (Also please take a peek at the other guidelines too! They're a great resource and help a lot to keep code clean. )

Also if you don't want to do those changes by hand, try using autopep8 which will attempt to clean it up for you (https://pypi.python.org/pypi/autopep8/). Flake8 (https://flake8.readthedocs.org/en/2.1.0/) is another tool that will go through your code and find non-pep8 compliant things and warn you about them.