PEP8 space after a comma

Bunyk picture Bunyk · Jul 31, 2015 · Viewed 7k times · Source

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):

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.

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?

Answer

Gary Sham picture Gary Sham · May 6, 2016

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.

According to their document:

E231 missing whitespace after ‘,’

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