逗号后的PEP8空格 [英] PEP8 space after a comma

查看:125
本文介绍了逗号后的PEP8空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行代码审查,并看到这样的方法声明:

I'm doing code review, and seeing method declarations like that:

def __init__(self,data):

我一直认为应该采用以下格式:

I always thought that it should be formatted like this:

def __init__(self, data):

但是随后,我检查了 PEP 0008 ,没有看到关于此的确切声明。有关于运算符周围和括号内空格的指南,但没有关于逗号分隔列表的指南。

But then I checked PEP 0008 and see no exact statement about that. There is guide about whitespace around operators, and inside parentheses, but no about comma separated list.

如果PEP8中未对此进行描述,则可能对此存在一些不成文的约定?为什么我确信这在PEP8中?大声的PEP8会更新吗?

If it is not described in PEP8, probably there is some unwritten convention about this? Why I was convinced that this was in PEP8? Shoud PEP8 be updated?

推荐答案

我也无法在PEP8中找到相应的句子,但我想大多数人认为此规则是PEP8中的 pip pep8

I can't find the corresponding sentence in PEP8 as well, but I guess the reason that most people believe this rule is in PEP8 is pip pep8.

根据他们的文档


E231在','之后缺少空格

E231 missing whitespace after ‘,’

因为大多数人将其用作样式检查器,很容易相信该规则确实存在于PEP8中。

As most people use this as their style checker, it is easy to be convinced that the rule is really in PEP8.

这篇关于逗号后的PEP8空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆