pep8

PyLint, PyChecker or PyFlakes? [closed]

流过昼夜 提交于 2019-11-26 12:48:58
问题 I would like to get some feedback on these tools on : features; adaptability; ease of use and learning curve. 回答1: Well, I am a bit curious, so I just tested the 3 myself right after asking the question ;-) Ok, this is not a very serious review but here is what I can say : I tried the tools with the default settings (it's important because you can pretty much choose your check rules) on the following script : #!/usr/local/bin/python # by Daniel Rosengren modified by e-satis import sys, time

How to break a line of chained methods in Python?

做~自己de王妃 提交于 2019-11-26 04:39:22
问题 I have a line of the following code (don\'t blame for naming conventions, they are not mine): subkeyword = Session.query( Subkeyword.subkeyword_id, Subkeyword.subkeyword_word ).filter_by( subkeyword_company_id=self.e_company_id ).filter_by( subkeyword_word=subkeyword_word ).filter_by( subkeyword_active=True ).one() I don\'t like how it looks like (not too readable) but I don\'t have any better idea to limit lines to 79 characters in this situation. Is there a better way of breaking it

Should I always specify an exception type in `except` statements?

别说谁变了你拦得住时间么 提交于 2019-11-26 01:34:07
问题 When using PyCharm IDE the use of except: without an exception type triggers a reminder from the IDE that this exception clause is Too broad . Should I be ignoring this advice? Or is it Pythonic to always specific the exception type? 回答1: It's almost always better to specify an explicit exception type. If you use a naked except: clause, you might end up catching exceptions other than the ones you expect to catch - this can hide bugs or make it harder to debug programs when they aren't doing