Indentation/whitespace

Steven D'Aprano steve at REMOVETHIScyber.com.au
Fri Dec 23 22:55:36 EST 2005


On Fri, 23 Dec 2005 15:22:39 -0800, thakadu wrote:

> It is not really unique to Python as I have pointed out on this or
> other forums before. The Occam (OCCAM?) language also uses significant
> whitespace in much the same way as Python and there may also be others.

Python doesn't have any more significant whitespace than any other
language:

x=12*sum([3,5,7,9,2][1:4])+3#comment

means the same thing as:

x = 12   * sum ( [   3 ,   5 , 7 , 9 , 2 ]  [ 1	 : 4 ] ) + 3 # comment

(although there are recommendations for where you should use whitespace).
You can mix spaces and tabs between tokens.

Like most computer languages, line breaks are significant in Python.
Nobody worries about that except maybe Forth programmers.

Also, *indentation* is significant, unlike most languages which treat
indentation as syntactically optional but enforce it via coding standards,
code beautifiers, pretty-printers, etc.


-- 
Steven.




More information about the Python-list mailing list