Why not allow empty code blocks?

Steven D'Aprano steve at pearwood.info
Sun Jul 24 10:32:38 EDT 2016


On Mon, 25 Jul 2016 12:05 am, BartC wrote:

>> No, it's an example of how *mixing tabs and spaces* can go wrong. And
>> in fact will always go wrong unless you legislate the width of a tab.
> 
> That's easy to say. How do you actually ensure that they aren't mixed?
> The software may not highlight the difference.

(1) Use a better editor.

(2) Use a linter that checks for dodgy indentation.

(3) Run the "tabnanny" module on your script:

python -m tabnanny myscripy.py

(4) Run Python 2.7 with the -t option to warn about inconsistent 
tab usage, or -tt to raise errors.

(5) Or for that matter any version of Python going all the way
back to Python 1.5, if not older. There has been no excuse for 
getting bitten by mixed tabs/spaces since at least 1998.

(6) Or upgrade to Python 3, which will automatically enforce the 
rule about not mixing tabs and spaces.



-- 
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list