2011年1月5日 星期三

[Python] 安裝Pyflakes Python語法檢查工具及設定Komodo Toolbox

pyflakes 是用來檢查Python程式語法用的, 可以提示未命名的變數或是沒用到(unused)的變數


passive checker of Python programs


Pyflakes is program to analyze Python programs and detect various errors. It works by parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster.


檢查結果如圖所示







安裝 pyflakes


easy_install pyflakes




在 Komodo上設定 pyflakes


1. Tools -> Run Command (Ctrl + R)
Run:  /usr/bin/pyflakes %F (填上你pyflakes執行檔路徑, ~$ which pyflakes )


2. 勾選 Add to Toolbox
3. 按More >>
4.Start in: 填上你的Project專案路徑例如  /home/pythonProjects/
5. Parse output with: ^(?P<file>.+?):(?P<line>\d+):(?P<content>.*)$
6. 勾選 Show parsed output as list
7. 按Run執行即可


你可以設置Key binding, 這樣在寫程式時就可以隨時檢查


在Toolbox 的設定結果如下




See Also


kevinw/pyflakes - GitHub
http://pypi.python.org/pypi/pyflakes
http://splike.com/wiki/Komodo_Pyflakes
PyFlakes installation and TextMate integration
Related Posts Plugin for WordPress, Blogger...