python代码解读软件_分析Python代码的好工具PyLint

Python code analysis can be a heavy subject, but it can be very helpful in making your programs better. There are several Python code analyzers that you can use to check your code and see if they conform. to standards.

Pylint is probably the most popular. It’s very configurable, customizable and pluggable too. It also checks your code to see if it conforms to PEP8, the official style. guide of Python Core and it looks for programming errors too. We’re going to spend a few minutes looking at some of the things you can do with this handy tool.

Getting Started

Sadly, pylint isn’t included with Python, so you’ll need to go out and download it from Logilab or PyPI. If you have SetupTools installed, then you can install it using easy_install, like this:

CODE:easy_install pylintNow you should have pylint installed and ready to roll!

Analyzing Your Code

The latest version as of this writing is 0.25.1. Once pylint is installed, you can run it on the command line without any arguments to see what options it accepts. Now we need some code to test with. Since I wrote some crummy code for my PyChecker article last year, we’ll re-use that here and see if pylint picks up the same problems. There should be four issues. Here’s the code:

CODE:01.import sys

02.

03.########################################################################

04.class CarClass:

05.""""""

06.

07.#----------------------------------------------------------------------

08.def __init__(self, color, make, model, year):

09."""Constructor"""

10.self.color = color

11.self.make = make

12.self.model = model

13.self.year = year

14.

15.if "Windows" in platform.platform():

16.print "You're using Windows!"

17.

18.self.weight = self.getWeight(1, 2, 3)

19.

20.#----------------------------------------------------------------------

21.def getWeight(this):

22.""""""

23.return "2000 lbs"

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/301743/viewspace-732928/,如需转载,请注明出处,否则将追究法律责任。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值