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

H

Harry George

Stephen Horne said:
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.

You can get away with file-by-file decisions in some languages, but
not python. As you refactor code among files, and as you do Extreme
Programming with someone using a different editor, you will kill
productivity if you are fussing with indents. Go with the guidleines
and that pain from "accidental complexity" (Brooks term) disappears.
 
S

Stephen Horne

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top