Improved Python code style

Removed unused imports, shortened functions

Refs #9345