I learned about Python and got the expandtabs command in Python. This is the official definition in the docs:
string.expandtabs(s[, tabsize])
Expand the tabs in a row, replacing them with one or more spaces, depending on the current column and the specified tab size. The number of reset columns is zero after each row of a new row in a row. It does not understand other non-printable characters or escape sequences. The default tab size is 8.
So, I realized from this that the default tab size is 8, and to increase it, we can use other values
So, when I tried this in a shell, I tried the following inputs -
>>> str = "this is\tstring" >>> print str.expandtabs(0) this isstring >>> print str.expandtabs(1) this is string >>> print str.expandtabs(2) this is string >>> print str.expandtabs(3) this is string >>> print str.expandtabs(4) this is string >>> print str.expandtabs(5) this is string >>> print str.expandtabs(6) this is string >>> print str.expandtabs(7) this is string >>> print str.expandtabs(8) this is string >>> print str.expandtabs(9) this is string >>> print str.expandtabs(10) this is string >>> print str.expandtabs(11) this is string
So here
0 completely removes the tab character,1 exactly matches default 8 ,- but
2 exactly matches 1 and then 3 different- and then again
4 like using 1
and after that it increments to 8 , which is the default, and then incrementing after 8. But why is there a weird pattern in numbers from 0 to 8? I know it should start at 8, but what is the reason?
Wutut
source share