Why does Python see the tab as 8 spaces?

Using a tab width of 4 spaces has become a major choice in programming. So why doesn't Python see the tab as 4 spaces instead of 8?

Is there a (technical, historical, other) reason for this design decision? It looks like this could have saved the developers from fighting inconsistent indentation.

+2


source to share


1 answer


Because the default tab size in Linux console is 8 spaces, and so most CLI text editors on Linux also have 8 spaces by default. Most are customizable as well, but that was the default for ages.



Some old (C) code uses mixed indentation to fake a bookmark 4 spaces - 1 indent == 4 spaces, 2 indents == 1 tab, 3 indents == 1 tab + 4 spaces, etc ... it was terrible. Not sure if this was done on purpose to make the code more readable, or if some editor did it automatically to simulate 4 spaces. All I know is that I was using pico and it was PITA working with them, especially when you needed to indent / highlight a whole block. :)

+2


source







All Articles