Hacker News new | ask | show | jobs
by michaelmior 3826 days ago
I'm not sure if you're trolling, but obviously not everyone would agree that this is the "proper way."
1 comments

I'm not. The obvious way to fix it would be to add a token signifying indenting one level. Why not choose the tab character as the token?
Obvious depends on your constraints.

Suppose (1) some of your newlines are indented but some are aligned for readability, and (2) mixing whitespace has a tendency to create subtle bugs.

Under those constraints, the only possible choice is spaces. Tabs can indent, but only spaces can either indent or align. Process of elimination forces you to prefer spaces over tabs in that situation.

This might be why PEP 0008 urges, "Spaces are the preferred indentation method." https://www.python.org/dev/peps/pep-0008/ [Specifically, four spaces.]

I had heard Google urged two spaces for indentation of Python, per some old style guide, but not sure if that's still followed or not.

Google's current Python style guide absolutely calls for two spaces. All of the languages I'm familiar with (at Google) do this. Except golang ...
... its almost as if it was entered into the character set for that precise purpose even. XD