nanaxnetworking.blogg.se

Taberror inconsistent use of tabs and spaces in indentation
Taberror inconsistent use of tabs and spaces in indentation





taberror inconsistent use of tabs and spaces in indentation

I don’t exactly know Python’s rules for intentation, but my model for “consistent indentation” would work something like:

#Taberror inconsistent use of tabs and spaces in indentation code#

I never use tabs in my own code, but I wouldn’t want to convert other people’s code to spaces just to run it in a future Python release, especially when the tab usage is universal. no reason to supply a special -ttt option.īut prohibiting tabs entirely might not go down well. I would be in favour of making the existing indentation behaviour more strict by default, or at least outputting some sort of warning for Evgeny’s examples. We should probably just introduce a new error mode (-ttt?) that makes it an error to use tabs at all for semantic indentation. However, it accepts this code:ĭespite its indentation being invalid if tab width is 10 or more.Īuthor: R. For example, Python rejects this code:īecause its indentation is invalid if tab width is 1. Prohibiting tabs after spaces is not enough. Tokens are generated for tab widths 1 and 8. The current implementation just checks if the same INDENT/DEDENT Then pep-008 is wrong, too, since the implementation *does* allow When using -tt these warnings become errors. When invoking the Python 2 command line interpreter with the -t option, it issues warnings about code that illegally mixes tabs and spaces.

taberror inconsistent use of tabs and spaces in indentation

Python 2 code indented with a mixture of tabs and spaces should be converted to using spaces exclusively. Python 3 disallows mixing the use of tabs and spaces for indentation. Tabs should be used solely to remain consistent with code that is already indented with tabs. Spaces are the preferred indentation method. Used for indentation with spaces following for formatting are I would go further and forbid tabs after spaces entirely. So, I think that the paragraph that I quoted above should be changed to match the actual behavior. However, their width would be different for any tab width except 1, 2, 4, and 8.Īctually, it's not easy to check that indentation is "consistent" as it is defined currently, so I think that it is the documentation that should be changed. For example, Python thinks that these two indentations are "consistent": 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 a TabError is raised in that case.īut that's not true. Mikko Rantalainen, abacabadabacaba, facundobatista, martin.panter, r.david.murray, serhiy.storchakaĬreated on 21:45 by abacabadabacaba, last changed 23:58 by facundobatista. TabError behavior doesn't match documentation







Taberror inconsistent use of tabs and spaces in indentation