Why indentation is use to denote block of code?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Sep 13 19:27:53 EDT 2009


On Sun, 13 Sep 2009 15:15:40 -0700, Chris Rebert wrote:

> In fact it's pretty much impossible to automatically indent Python code
> that has had its indentation removed; it's impossible to know for sure
> where the dedents should occur.


Just like most other syntactic elements -- if you remove all the return 
statements from Python code, or dot operators, it's impossible to 
automatically add them back in.

The only difference is that some (badly written?) applications mangle 
leading whitespace, but very few feel free to remove other text on a whim.

I don't recall actually using a mail client or newsreader that removes 
leading whitespace when posting, but I've occasionally seen posts from 
others with all indentation removed, so presumably such badly-behaved 
applications do exist.


-- 
Steven



More information about the Python-list mailing list