我有这样的目录结构/path/to/dir/a/foo/path/to/dir/b/foo并且想在目录/path/to/dir/上运行pep8,不包括/path/to/dir/a/foopep8--exclude='/path/to/dir/a/foo'/path/to/dirpep8的预期输出是,它不应该包含来自/a/foo/的文件但pep8也在检查/a/foo/中的文件当我这样做时pep8--exclude='foo'/path/to/dir它从a/foo/b/foo/中排除文件pep8排除选项的模式是什么,以便它仅从/a/foo/而不是从b/foo/中排除文件?
PEP257说:Docstringprocessingtoolswillstripauniformamountofindentationfromthesecondandfurtherlinesofthedocstring,equaltotheminimumindentationofallnon-blanklinesafterthefirstline.Anyindentationinthefirstlineofthedocstring(i.e.,uptothefirstnewline)isinsignificantandremoved.Relativeindentationoflater
我一直在看PEP8--StyleGuideforPythonCode和PEP8--AdvancedUsage有关如何命名我的测试类的线索。但是,这两个站点以及我查看过的许多其他站点(例如Python文档中的unittest页面)都没有提到这一点。我看到的唯一一致的风格是“CapWords”。在unittest文档中,他们有TestSequenceFunctions和DefaultWidgetSizeTestCase的示例。我想知道是使用“名称”测试还是测试“名称”。方法使用test_"name"这已经很成熟了。关于类(class),我正在努力寻找一个约定,如果有的话。感谢论坛对此的帮助
我有这行代码,在测试pep8错误时我得到:线太长。因此,为了尝试解决此问题,我使用了slash('\')但随后我将延续行过度缩进以进行视觉缩进。我该怎么做才能解决这个问题?我尝试过的事情:iffirst_index\self._number_of_plates-1:raiseValueErrorcontinuationlineover-indentedforvisualindentiffirst_index\self._number_of_plates-1:raiseValueErrorcontinuationlineover-indentedforvisualindentiffirs
这个问题在这里已经有了答案:HowtowriteverylongstringthatconformswithPEP8andpreventE501[duplicate](13个回答)关闭5年前。我在项目中有很多这样的长行,不知道如何打破它以保持PEP8快乐。PEP8显示来自.format(me['id'])的警告pic_url="http://graph.facebook.com/{0}/picture?width=100&height=100".format(me['id'])我怎样才能断行以摆脱PEP8警告但又不破坏代码? 最佳答案
我使用vim编辑器作为pythonIDE。下面是一个简单的python程序来计算一个数的平方根:importcmathdefsqrt():try:num=int(input("Enterthenumber:"))ifnum>=0:main(num)else:complex(num)except:print("OOPS..!!Somethingwentwrong,tryagain")sqrt()returndefmain(num):squareRoot=num**(1/2)print("ThesquareRootof",num,"is",squareRoot)returndefcompl
PEP8信息:models.py:10:80:E501linetoolong(83>79characters)模型.py:field=TreeForeignKey('self',null=True,blank=True,related_name='abcdefgh')如何正确书写这一行? 最佳答案 这是“正确的”,PEP8只是标记长度超过79个字符的行。但如果你担心这个,你可以这样写:field=TreeForeignKey('self',null=True,blank=True,related_name='abcdefgh')或者
我有这个代码:some_list=range(a,b+1)使用pep8pluginforvim检查我的编码风格后,我收到了这个警告:missingwhitespacearoundoperator似乎为了符合PEP8我应该改写这个?some_list=range(a,b+1)但我读过PEP8-StyleGuideforPythonCode几次,就是找不到适用于上述警告的规则。所以我想知道:当使用PEP-8样式时,函数参数中的运算符(+、-、*、/等)周围是否需要空格? 最佳答案 当你在2013年问的时候,你的Vim插件是错误的……但在
我正在使用PyCharm(v2.7.2)开发一个Django应用程序,但我无法使用它来检查PEP8样式违规。我在设置的“检查”部分启用了“PEP8编码样式违规”,但PyCharm没有突出显示样式违规。有没有办法解决这个问题? 最佳答案 由于配色方案,我的没有出现。默认情况下,它被标记为“弱警告”,因此您可能需要编辑外观以使其可见。编辑器>颜色和字体>常规>错误和警告。 关于python-如何让PyCharm检查PEP8代码样式?,我们在StackOverflow上找到一个类似的问题:
我正在尝试正确缩进以下代码:RULES_LIST=[('Name1',1,'Longstringupto40chars'),('Name2',2,'Longstringupto40chars'),('Name3',3,'Longstringupto40chars'),('Name4',4,'Longstringupto40chars'),('Name5',5,'Longstringupto40chars'),('Name6',6,'Longstringupto40chars'),('Name7',7,'Longstringupto40chars'),('Name8',8,'Longst