Quang Lê Duy added the comment:
Reading from the source code (Parser/tokenizer.c from line 1364 as in Python
3.10), I derive these as the actual indentation rules:
– Tab makes the indentation amount the next multiple of 8.
– Among lines with the same indentation amount in the same parent line,
Carol Willing added the comment:
Assigning this to @Mariatta, to be worked on the mentored sprint at PyCon US
Cleveland. Verify behavior and update documentation.
--
assignee: docs@python -> Mariatta
nosy: +Mariatta, willingc
___
Python tracker
Jérôme LAURENS added the comment:
To be more precise, consider code
def f(x):
\tx=0 # 7 spaces + one tab
return x # 8 spaces
In cpython, both indentation levels are 8 and no indentation error is reported
(this is the case where both tab size and alt tab size are equal)
If
New submission from Jérôme LAURENS :
https://docs.python.org/3/reference/lexical_analysis.html#indentation reads
Point 1:
"Tabs are replaced (from left to right) by one to eight spaces such that the
total number of characters up to and including the replacement is a multiple of
eight"
and in