PEP8 and 4 spaces
steve+comp.lang.python at pearwood.info
Fri Jul 4 03:02:40 CEST 2014
On Thu, 03 Jul 2014 10:31:04 -0700, Tobiah wrote:
> Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer
> tabs. Boss want's us to unify.
Point out to your boss, and your co-worker, that PEP 8 *explicitly*
states that it is not compulsory except for the standard library, and
that for third-party and private code, local conventions over-rule PEP 8.
In other words, if your co-worker is the only one who uses spaces when
everyone else uses tabs, **he is violating PEP 8**.
> The sole thing you get with spaces as
> far as I can tell, is that someone loading the code into Notepad will
> still see a 4 character indent. That may be true, but that same person
> is going to have a difficult time editing the code.
Advantages of spaces:
- It's a convention that many people follow.
Disadvantages of tabs:
- Many standard Unix/Linux/POSIX tools have a hard time dealing with tabs.
I call such tools *broken*, and there is a vicious circle going on:
programmers use the fact that these tools don't support tabs to justify
the use of spaces, and the majority consensus that you should use spaces
as justification for not fixing the tools.
As I understand it, Unix coders tend to prefer spaces, and Windows users
tend to be more comfortable with tabs. This isn't a hard-and-fast rule,
you'll find plenty of exceptions, but it seems to me that Unix tools are
unforgiving of tabs while Windows IDEs tend to default to tabs. I'm not a
Windows person myself, any Windows guys like to comment?
> Anyway, I gave up the 80 char line length long ago, having little
> feeling for some dolt on a Weiss terminal that for some reason needs to
> edit my code.
How do you feel about some dolt who aligns two or three editor windows
side-by-side so they can compare code? :-)
Being able to set code side-by-side, say in a horizontal diff, or two
editors next to each other, is a much more important reason to support a
79+1 maximum line width than Weiss terminals.
More information about the Python-list