[issue35957] Indentation explanation is unclear

2021-10-23 Thread Quang Lê Duy

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, the 
total number of tabs and spaces must match, in other words, the tabs' total 
padded width must be equal.
– If it's an indent, the total number of spaces and tabs must exceed that of 
the parent line.

--
nosy: +leduyquang753

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35957] Indentation explanation is unclear

2019-02-18 Thread Carol Willing


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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35957] Indentation explanation is unclear

2019-02-12 Thread Jérôme LAURENS

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 instead of 8 the tab would count for 6 spaces, then we would have 12 and 8 
as indentation level, resulting in a mismatch and an indentation error being 
reported, according to the documentation. This is inconsistent.
Then either the documentation is faulty or cpython is.

Actually, cpython accepts a mix of space and tabs only when tabs are in 8, 16, 
24... positions.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35957] Indentation explanation is unclear

2019-02-10 Thread Jérôme LAURENS

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 the next paragraph

Point 2:
"Indentation is rejected as inconsistent if a source file mixes tabs and spaces 
in a way that makes the meaning dependent on the worth of a tab in spaces"

In point 1, each tab has definitely a unique space counterpart, in point 2, 
tabs may have different space counterpart, which one is reliable ?

The documentation should state that Point 1 concerns cPython, or at least 
indicate that the 8 may depend on the implementation, which then gives sense to 
point 2.

--
assignee: docs@python
components: Documentation
messages: 335165
nosy: Jérôme LAURENS, docs@python
priority: normal
severity: normal
status: open
title: Indentation explanation is unclear
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com