well,
1. you can leverage the tool (editor tools)
2. you can run the library code py_compile. example :
python -m py_compile script.py
References:
How can I check the syntax of python code without actually executing it.. : http://stackoverflow.com/questions/205704/how-can-i-check-the-syntax-of-python-code-in-emacs-without-actually-executing-it