On 05Dec2014 17:40, Aahan Krish <kr...@aahan.me> wrote:
*Q1.* This is not to debate the decision, but I really wanted to know the
reason why PEP 8 chose to go with spaces instead of tabs. I read that tabs
were initially preferred over spaces (esp. Mr. Rossum)? What caused the
decision that spaces are better?

Essentially because the space is always the same.

According to Core Python Programming (Book):
...because tabs vary in the number of spaces depending on your system, we
recommend not using tabs if there is any hint of cross-platform development.

Isn't that a feature of tabs? (i.e. allowing the user to configure the size
of a tab stop in his editor, which has no affect whatsoever on the tab
character itself or how it displays in another user's editor.)

Yes, but in practice it causes varying degrees of pain.

Ideally, the various pieces of code have differing indents and that would be specified entirely with tabs. In practice, (1) people mix them and (2) people make other formatting decisions based on the rendering width of tabs in whatever editor they're using at the time, particularly with multiline strings such as docstrings.

There are two common approaches to TABs: the purists who uses TABs entirely so that other users can align the code as they see fit, and the pragmatists who configure their editors to accept the TAB _keystroke_ and have it insert spaces according to their tab convention.

I'm in the latter category; I have spent too much time reading files indented with TABs by people using a different tabwidth to my own, and thus looking aweful on my screen. The original author didn't choose to make it awful, but their tabs rendered in my tab scheme look awful. And doubtless vice versa. The root cause of this is that when we, as humans, indent with tabs, we do it to achieve a certain visual effect; as though a certain number of spaces were in play.

So my editor is configured to accept the tab key for convenience of typing, but to insert spaces.

Cheers,
Cameron Simpson <c...@zip.com.au>

In My Egotistical Opinion, most people's C programs should be indented six
feet downward and covered with dirt.    - Blair P. Houghton
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to