You should move the import to the top.

> Imports should be grouped in the following order:
>  1. standard library imports
>  2. related third party imports
>  3. local application/library specific imports

quote from http://legacy.python.org/dev/peps/pep-0008/#imports