The net effect is that you can write things like
or initialize lists as follows:
months = ['Jan', 'Feb', 'Mar', # first Q
'Apr', 'May', 'Jun', # second Q
'Jul', 'Aug', 'Sep', # third Q
'Oct', 'Nov', 'Dec'] # fourth Q
(Code using backslashes still works, but note that a line can't have a
backslash *and* a comment, so there's a definite improvement here.)
A drawback is that if you accidentally forget a closing parenthesis,
you might get a syntax error on the next line or even further down.
Usually this will be on the first token of the next line though (since
most tokens that can start a statement can't continue an expression --
the exception being open parentheses and brackets). A way to
alleviate this problem would be to print the entire current *logical*
line when a syntax error has occurred.
Ideally, one would like a syntax where a line can be broken without a
backslash anywhere where the syntax doesn't allow a newline token.
This would allow things like
if very_long_condition and _another_long_condition and
yet_another_condition and another_one_again:
(but still not this:
print 1, 2, 3,
4, 5, 6
x = 1, 2, 3,
4, 5, 6
-- do you see why not?)
However, such a change would require a much bigger change to the
parser and tokenizer (apart from the difficulties in spelling out
*exactly* what the rules would be, for future generations).
I feel that this mod would be a useful addition to Python (also it
fits nicely in the tradition of carefully trading certain principles
What do you think?
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>