You need to distinguish between A. Tab length when convert tabs in your source code to spaces and B. Tab length when python expand tab escape sequence
A. converting tab to certain number of spaces (default=4) is feature of your IDE (in your case IDLE). Here the more important part is the conversion of tab to spaces (as PEP8 recommends to use spaces for indentation in the source code).
B. If you look at str.expandtabs(tabsize=8) method you will see that default tabsize value is 8. It's safe bet this is default/standard tabsize (i.e. even when not call expandtabs() method).
If you want to get different tab length
\t
, e.g. when printing string.A. converting tab to certain number of spaces (default=4) is feature of your IDE (in your case IDLE). Here the more important part is the conversion of tab to spaces (as PEP8 recommends to use spaces for indentation in the source code).
B. If you look at str.expandtabs(tabsize=8) method you will see that default tabsize value is 8. It's safe bet this is default/standard tabsize (i.e. even when not call expandtabs() method).
If you want to get different tab length
>>> print("Line 1\n\tLine 2") Line 1 Line 2 >>> print("Line 1\n\tLine 2".expandtabs(4)) Line 1 Line 2 >>>
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs