Be gentle with me....

t. middleten t.middleten at news.vex.net
Sat Dec 4 03:26:21 EST 1999


On Fri, 03 Dec 1999 16:19:04 GMT, Preston Landers wrote:
>> want to continue a line of code over multiple physical lines?
>
>x = "This is a \
>  line of code \
>  spanning multiple \
>  lines"

Although the original poster asked about code spanning lines, and the
above example, while in a string, demonstrates the concept, i want to
point out that the above string will produce...

"This is a   line of code    spanning multiple   lines"

(For that ugly effect you might as well use multi-line quotes...

x = """This is a 
  line of code 
  spanning multiple 
  lines"""

)

However, to demonstrate the concept of multi-line code AND keep the 
spacing nice in our string, this works best...

x = "This is a " \
  "line of code " \
  "spanning multiple " \
  "lines"








More information about the Python-list mailing list