Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Are line continuations needed?

Reply
Thread Tools

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
 
Reply With Quote
 
 
 
 
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
 
Reply With Quote
 
 
 
 
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

 
Reply With Quote
 
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)
-------------------------------------------------------------------
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PEP8, line continuations and string formatting operations Gerald Britton Python 1 01-21-2011 11:39 PM
RFC 822 continuations Florian Lindner Python 2 05-02-2006 07:57 PM
Ruby/Python Continuations: Turning a block callback into a read()-method? Robert Python 0 02-12-2006 08:14 PM
Continuations Based Web Framework - Seaside. Mike Thompson Python 17 01-04-2005 01:08 AM
RE: Are line continuations needed? Batista, Facundo Python 9 04-09-2004 08:42 AM



Advertisments