Re: the war on trailing whitespace
- From
Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>
- Date
- Feb 27, 2006, 16:37 UTC
- Message-ID
- <20060227163709.GA12538@informatik.uni-freiburg.de>
- In-Reply-To
- <4403086F.5040704@op5.se>
Andreas Ericsson wrote:
Show 17 quoted lines
> Uwe Zeisberger wrote: > >Hello, > > > >Andreas Ericsson wrote: > > > >>I think the question is whether completely empty lines are also ignored > >>by Python, or if they start a new block of code. Whatever the case, it > >>must hold true for both 2.3 and 2.4. > > > >see > > http://www.python.org/doc/2.2.3/ref/blank-lines.html > > http://www.python.org/doc/2.3.5/ref/blank-lines.html > > http://www.python.org/doc/2.4.2/ref/blank-lines.html > > > > So in essence, a multi-line statement is closed when a completely empty > line is found,
Wrong.
A logical line that contains only spaces, tabs, formfeeds and possibly a comment, is ignored (i.e., no NEWLINE token is generated). During interactive input of statements, handling of a blank line may differ depending on the implementation of the read-eval-print loop. In the standard implementation, an entirely blank logical line (i.e. one containing not even whitespace or a comment) terminates a multi-line statement.
To translate that to python:
if not interactive:
a line only containing whitespace is ignored.
else:
if standard implementation:
empty line terminates multi-line statement
else:
dependent on implementationi.e. In scripts, lines containing only (zero or more) whitespaces are ignored.
hth Uwe
-- Uwe Zeisberger Set the I_WANT_A_BROKEN_PS environment variable to force BSD syntax ... -- manpage of procps