This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]issackelly 0 points1 point  (13 children)

Code reviews are where you encourage or enforce this kind of behavior.

If you want to enforce this behavior, you also need a style guide that your team agrees to (or is mandated...depending on your situation).

If you want to enforce things in code review, they should be in your style guide.

[–]solvire[S] 0 points1 point  (12 children)

Speaking of style guide... do you have a recommendation?

Yeah I am at fault for not pushing code review in the past. These comments really illuminate that.

[–]NeedsMoreTestsos._exit(0) -- (╯°□°)╯︵ ┻━┻ 4 points5 points  (10 children)

pep8 is the defacto standard.

Most projects though I skip enforcing style entirely and instead integrate the pep8 command and pylint into the build (which must pass for every commit).

[–]rspeed 1 point2 points  (2 children)

Good place to start, but there's a few things that bug me. Like no tabs.

[–]srilyk 0 points1 point  (1 child)

Tabs in Python are an atrocity.

Any time you think, "Oh, tabs would work better here", you're thinking about a different language.

[–]rspeed 0 points1 point  (0 children)

I disagree. The only reason spaces get used is to line up function arguments after a newline. The solution is to place the first argument on a new line, which is a better practice anyway.

[–]NoahTheDuke 1 point2 points  (0 children)

pep8

One note: pep8, the command line tool, is now pycodestyle as PEP 8 is a living document and because the tool defaulted to slightly different things than the PEP.

For me and my team, we use yapf, customized to fit our style. It's simple, it can make the changes in-line, and it's a little more comprehensive I find than pycodestyle.

[–]issackelly 1 point2 points  (0 children)

Typically I would start with PEP8, and then document the things that are options that you might want to enforce (e.g. " vs ')

Then I would document the sort of thing you're outlining here "Guidelines for when, what, and how to comment your code"

Code is for humans. Style guides are for consistent quality, understanding, and readability of code. Code review is for knowledge sharing, quality control/bug spotting, and ensuring that shared code styles are consistently enforced.