[Tutor] Pep 8, about indentation

Steven D'Aprano steve at pearwood.info
Thu Aug 6 05:40:08 CEST 2015

On Thu, Aug 06, 2015 at 02:24:49AM +0100, Alan Gauld wrote:
> On 06/08/15 00:31, D Wyatt wrote:
> >I clearly remember that the standard for Python was to use 2 spaces
> Nope, unless it was a local convention in your place of work.
> But the standard for indentation has always(*) been 3 or 4 and fro PEP 8 
> its 4. And thats pretty standard in any language because its the size of 
> indent that gives best clarity to the code. (Based on tests of students 
> reading code samples.)

Um, the oldest standard for TABs is *eight* spaces, not 3 or 4, and 
using eight-space indents is still very common. Vim, apparently, 
defaults to 8 space indents when you hit the tab key. Gofmt (used by the 
Go language) defaults to 8 spaces; even Python does in places:

    S.expandtabs([tabsize]) -> str

    Return a copy of S where all tab characters are expanded using 
    spaces. If tabsize is not given, a tab size of 8 characters is 

The Linux kernel developers use 8 space indents, and consider that 
important enough that it is the very first item in their style guide:


For interest, here's a survey done by Perl programmers in 2002:



More information about the Tutor mailing list