15

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?

5 Answers 5

18
python -m py_compile script.py
Sign up to request clarification or add additional context in comments.

Comments

8

You can use Pyflakes together with Flymake in order to get instant notification when your python code is valid (and avoids a few common pitfalls as well).

3 Comments

The domain plope.org in this URL does not exist anymore, hence the documentation is not anymore available.
I updated it to an archive.org version. Hopefully this gets you the info you need :)
Yes but even better is to copy here the relevant stuff.
2

Or from emacs (or vim) you could run python -c 'import x' where x is the name of your file minus the .py extension.

Comments

0

You can use pylint for such things and there seems to be a way to integrate it into emacs, but I've never done the latter b/c I'm a vim user.

Comments

0

You can use pylint, pychecker, pyflakes etc. from Emacs' compile command (M-x compile).

Hint: bind a key (say, F5) to recompile.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.