Hacker News new | ask | show | jobs
by tetha 2547 days ago
In my book, the answer has always been: tabs for indentation, spaces for alignment. Tabs allow everyone to choose the gap for new blocks they like, and spaces make sure that a gap of 16 characters is always a gap of 16 characters (because whatever you align with is 16 characters long).

Practically, I eventually got fed up explaining this. Spaces only is easier to explain, because there is very little to get wrong with "spaces only".

1 comments

Python 3 won't compile with mixed indentation so by recommending a mixture you're picking a fight you cannot win and still have python programmers along with you.
Seems like it will to me. Here's an example using tabs for indent and spaces for alignment:

https://repl.it/repls/SubduedLegalDisk

I can't follow that link but I'll trust you, I was just going off what the documentation had to say: https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces

My reading of "Disallow" must be wrong.

As long as you always “indent” with tabs and only use spaces after, you’re good, I believe. That is, if you want to align something, you just first indent to the level of the previous line with tabs and then you can use spaces for alignment within that indentation level. What you can’t do is, for example, have a space and then a tab.