Why Python style guide (PEP-8) says 4 space indents instead of 8 space??? 8 space indents ever ok??

Stephen Horne steve at ninereeds.fsnet.co.uk
Mon Oct 27 11:20:37 EST 2003


On Mon, 27 Oct 2003 08:36:04 GMT, Harry George
<harry.g.george at boeing.com> wrote:

>If you never work with others, never edit code from others, and never
>offer code to the OSS world, then I suppose you can do your own indent
>rules.

That is emphatically *not* my situation. OK, I've made no significant
contribution to the open source world (yet) but as a professional
programmer, working with code that was produced by someone else (and
usually maintained by a number of people), and writing code to be read
by someone else is just a basic fact of everyday life.

My experience is that the size of indent really doesn't make much
difference as long as it is consistent in each file - you get roughly
the same number of complaints no matter what length you choose.

At work, there isn't really a set rule that I'm aware of. Most people,
when creating a new file, tend to go with either two or four space
indents, though there are a couple of eight-spacers too, but it really
isn't a big thing. It doesn't create unreadable chaos, it just means
some files have wider indents than others.

And yes, any half-decent editor can be set up to indent properly to
any width. Mine are set up to use two space indents. But because I
also regularly end up using new editors (which I've not yet figured
out how to set up correctly), or simple editors (sometimes notepad
does the job simply because it is there) or editors set to someone
elses preferences, or files which use indent levels different to my
preferences, my habit is to avoid the tab key altogether and just use
the space key. That way, if I forget that a particular editor has not
yet been set up to use spaces instead of tabs, I don't get a file
using mixed tabs and spaces for instance.


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list