Velocity Reviews > Are line continuations needed?

# Are line continuations needed?

Russell Wallace
Guest
Posts: n/a

 04-07-2004
On Wed, 07 Apr 2004 17:53:00 GMT, Christopher Koppler
<(E-Mail Removed)> wrote:

>On Wed, 07 Apr 2004 14:05:29 GMT, http://www.velocityreviews.com/forums/(E-Mail Removed) (Russell
>Wallace) wrote:
>
>>Python lets you continue a single logical line across more than one
>>physical line, either by putting a \ at the end or letting it happen
>>automatically with an incomplete infix operator.

>
>I don't have any ready examples, but I do occasionally need it, if
>only for readability porpoises, or more often to fit a line to a
>certain length limit. If a parenthetical expression will work, and
>doesn't look stranger (really can't think of a case), I'll use that.

Okay, thanks.

>But problems there'll surely be - with legacy code compatibility.

*nod* I was more asking whether it was a good idea to include it
originally than whether it could be removed now, though I suppose
since 3.0 is supposed to be breaking with backward compatibility,
there's the question of whether it should be retained there.

>Not really it isn't

^.^

--
"Sore wa himitsu desu."
To reply by email, remove
the small snack from address.
http://www.esatclear.ie/~rwallace

Heather Coppersmith
Guest
Posts: n/a

 04-07-2004
On Wed, 07 Apr 2004 14:05:29 GMT,
(E-Mail Removed) (Russell Wallace) wrote:

> Python lets you continue a single logical line across more than
> one physical line, either by putting a \ at the end or letting
> it happen automatically with an incomplete infix operator.

> I'm wondering how often is this feature needed? Would there be
> any problems if it weren't part of the language?

Completely contrived:

if a == b or b == c or c == d or d == e or e == f or f == g ....

No, I can't imagine this sort of thing actually coming up, and
yes, it's "fixable" with some extra parenthesese:

if (a == b or b == c or c == d) or (d == e or e == f
or f == g ....

Regards,
Heather

--
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli

Jeff Epler
Guest
Posts: n/a

 04-08-2004
I would not miss \-continuations much.

I think you're mistaken about continuations "automatically with an
incomplete infix operator":
>>> 1 +

File "<stdin>", line 1
1 +
^
Did I misunderstand what you meant?

I would sorely miss lines continued due to the presence of nesting
expressions, like
d = {
'x': 1,
'y': 2
}
and
if (x == 3
and y == x * 4):
return True
These kinds of continued lines are IMO easier to get right than
\-continuations, because those rely on absence of whitespace in a place
where the presence rarely makes a visible difference (backslash space
newline is not a continuation).

Jeff

Peter Maas
Guest
Posts: n/a

 04-08-2004
Peter Otten wrote:
>>d = { 'key1' : 'A very very long string of several hundred '\
>> 'characters. I could use a multi-line string but '\

[...]
>>>>d = {1: "Hi Peter, "

>
> ... "what do you "
> ... "think of this?"}

You got me I know implicit line continuation but thought that
it applies only to cases where the strings are direct elements of
the bracket like in ["s1", "s2"]. OK, then my example should read

s = 'A very very long string of several hundred '\
'characters. I could use a multi-line string but '\
[...]

If there are more than three lines you will type less with a
pair of brackets.

Mit freundlichen Gruessen,

Peter Maas

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail (E-Mail Removed)
-------------------------------------------------------------------