PEP8 and 4 spaces

Chris Angelico rosuav at gmail.com
Thu Jul 3 13:38:27 EDT 2014


On Fri, Jul 4, 2014 at 3:31 AM, Tobiah <tshepard at rcsreg.com> wrote:
> Coworker takes PEP8 as gospel and uses 4 spaces
> to indent.  I prefer tabs.  Boss want's us to
> unify.

1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast rules.
2) Tabs let different people display the indents at different widths.
You want it to look like four spaces? No problem. You think it looks
better at eight? Fine, set your display to eight. Easy.
3) Perhaps most importantly: You don't have to unify. Let your source
control system do the work for you. In git, that's the smudge/clean
filters and gitattributes; I don't know the mechanics in hg, but I'm
sure it'll exist; in other systems, you might have to rig something
up, or dig through the docs. But you should be able to settle on one
thing in source control and let everyone check out files in whatever
way they like.

Personally, I like, use, and recommend, tabs - but the next best thing
to tabs is a consistent number of spaces (preferably four). But if you
can't make your tools handle the difference, you're going to be
putting unnecessary strains on the humans. Let the humans work with
whatever they prefer.

ChrisA



More information about the Python-list mailing list