Python's IDLE has 'Check Module' (Alt-X) to check the syntax which can be called without needing to run the code. Is there an equivalent way to do this in Emacs instead of running and executing the code?
Or from emacs (or vim) you could run python -c 'import x' where x is the name of your file minus the .py extension.
How can I check the syntax of Python code in Emacs without actually executing it?