Why not allow empty code blocks?

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun Jul 24 20:40:05 EDT 2016


BartC wrote:
> On 24/07/2016 14:24, Chris Angelico 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.

Python 3 will tell you immediately, since it forbids
mixing tabs and spaces.

 >>> def f():
...  a
...     b
   File "<stdin>", line 3
     b
     ^
TabError: inconsistent use of tabs and spaces in indentation

> So I still think it's fragile, meaning you have to take a lot of extra 
> care.

The practical experience of a very large number of Python
programmers suggests that it requires very little additional
care over and above that normally required for programming.

What's your experience? How often has this caused you trouble,
and what proportion is it of all the Python programming you've
done?

-- 
Greg



More information about the Python-list mailing list