PyChecker使用指南

               

转载:http://blog.csdn.net/thoughtwise/article/details/5719455


简介

PyChecker是一个对Python源代码进行语法检查的工具。

主页:http://pychecker.sourceforge.net

PyChecker is a static analysis tool for finding bugs in Python source code. It finds problems that are typically caught by a compiler for less dynamic languages, like C and C++. It is similar to lint.

 

目前最新版本是2008-08-18 更新的pychecker-0.8.18。

 

安装

前提:本地安装好Python2.x, 推荐2.6版本,虽然2.7版本也发布了。3.0版差异太大,相当于全新版本,不保证兼容性,不推荐使用。

最好将IPython也一并安装了。

 

下载地址:http://sourceforge.net/projects/pychecker/

从网页上下载pychecker-0.8.18.tar.gz,解压。

然后在pychecker-0.8.18目录(其下有setup.py脚本), 执行命令行python setup.py install 执行安装。这也是在Windows下python软件的通用安装方式。

 

使用

 

安装好后,试试在pychecker-0.8.18目录执行命令行pychecker setup.py,检查setup.py的语法

E:/pychecker-0.8.18>pychecker setup.py

E:/pychecker-0.8.18>C:/Python26/python.exe C:/Python26/Lib/site-packages/pychecker/checker.py se
tup.py
Processing module setup (setup.py)...

Warnings...

C:/Python26/lib/distutils/command/bdist_wininst.py:271: Statement appears to have no effect

C:/Python26/lib/distutils/command/build_scripts.py:80: No class attribute (dry_run) found
C:/Python26/lib/distutils/command/build_scripts.py:97: No class attribute (dry_run) found
C:/Python26/lib/distutils/command/build_scripts.py:120: (file) shadows builtin
C:/Python26/lib/distutils/command/build_scripts.py:121: No class attribute (dry_run) found

C:/Python26/lib/distutils/command/install_data.py:62: (dir) shadows builtin
C:/Python26/lib/distutils/command/install_data.py:64: (dir) shadows builtin
C:/Python26/lib/distutils/command/install_data.py:66: (dir) shadows builtin

C:/Python26/lib/distutils/command/install_scripts.py:52: (file) shadows builtin
C:/Python26/lib/distutils/command/install_scripts.py:53: No class attribute (dry_run) found

19 errors suppressed, use -#/--limit to increase the number of errors displayed

 

这里pychecker 是个bat脚本,实际执行的是C:/Python26/python.exe C:/Python26/Lib/site-packages/pychecker/checker.py 。

 

这里检查结果将setup.py依赖的文件中语法错误或告警也检查出来了。

 

如果只想检查setup.py自身的语法,可以用--only参数

E:/pychecker-0.8.18>pychecker --only setup.py

E:/pychecker-0.8.18>C:/Python26/python.exe C:/Python26/Lib/site-packages/pychecker/checker.py --only setup.py
Processing module setup (setup.py)...

Warnings...

None

更多的参数,可以使用pychecker --help查看



           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值