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?
A Foolish Consistency is the Hobgoblin of Little Minds One of Guido's key insights is that code is read much more often than it is written. The guidelines provided here are intended to improve the readability of code and make it consistent across the wide spectrum of Python code.
While the Python style guide does say spaces are the preferred method of indentation when coding in Python, you can use either spaces or tabs.
Pep8 is a coding standard and Style Guide for readability and long-term maintainability. It's not a requirement for your code to work, just a good coding practice you should follow. There are also some automated tools you can use to help make your source code pep8 and other linters. Here's an example of one.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With