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?
Python的IDLE有'Check Module'(Alt-X)来检查可以调用的语法而无需运行代码。是否有相同的方法在Emacs中执行此操作而不是运行和执行代码?
5 个解决方案
#1
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).
您可以将Pyflakes与Flymake一起使用,以便在您的python代码有效时获得即时通知(并避免一些常见的陷阱)。
#2
18
python -m py_compile script.py
#3
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.
或者从emacs(或vim)中运行python -c'import x',其中x是文件名减去.py扩展名。
#4
#5
0
You can use pylint, pychecker, pyflakes etc. from Emacs' compile
command (M-x compile
).
您可以使用Emacs的编译命令(M-x编译)中的pylint,pychecker,pyflakes等。
Hint: bind a key (say, F5) to recompile
.
提示:绑定一个键(比方说,F5)来重新编译。
#1
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).
您可以将Pyflakes与Flymake一起使用,以便在您的python代码有效时获得即时通知(并避免一些常见的陷阱)。
#2
18
python -m py_compile script.py
#3
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.
或者从emacs(或vim)中运行python -c'import x',其中x是文件名减去.py扩展名。
#4
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.
你可以使用pylint来做这些事情,似乎有办法将它集成到emacs中,但我从来没有做过后者b / c我是vim用户。
#5
0
You can use pylint, pychecker, pyflakes etc. from Emacs' compile
command (M-x compile
).
您可以使用Emacs的编译命令(M-x编译)中的pylint,pychecker,pyflakes等。
Hint: bind a key (say, F5) to recompile
.
提示:绑定一个键(比方说,F5)来重新编译。