line continuation for lines ending in "and" or "or"
Terry Reedy
tjreedy at udel.edu
Thu Jun 5 16:40:44 EDT 2008
"Russ P." <Russ.Paielli at gmail.com> wrote in message
news:0d723e6d-f81b-4545-b406-fc60b20c5433 at u6g2000prc.googlegroups.com...
|. Well, it wouldn't be a bad idea for Python to do
| what I thought it did, *plus* what I said it ought to do.
A line ending in an operator is ambiguous in that it *could* indicate that
the programmer intends to continue on the next line while it also could
indicate that the programmer forgot to finish before hitting return, or
that something got erased but not replaced. Moreover, the second
possibility is actual (it actually happens) and not just theoretical.
Moreover, the next line realistically could 'complete' the incomplete line
'by accident', so that the syntax bug would not get flagged.
In such situations, some might lean toward the plausible guess choice, but
Guido leans in the direction of choosing the bug interpretation. So he
included the '\' mechanism. It is already used in strings to mean "do not
take the next char literally", so having it mean "do not take the following
end-of-line literally" is only a tiny step.
Terry Jan Reedy
More information about the Python-list
mailing list