long lines, long string

david_ullrich at my-deja.com david_ullrich at my-deja.com
Wed Jun 28 13:03:59 EDT 2000


In article <j9tcj8.i0b.ln at iiab.soluma.de>,
  "Holger M. Füßler" <fuessler at solutec.de> wrote:
> Hallo!
>
> Is there a possibility to put long lines of python-source-code in
multiple
> lines (for better clarity)?
> How can I accomplish the same with strings?

    Triple quotes allow you to include line breaks
in a quoted string. Putting a back-slash at the end
of a line tells Python to ignore the line break and
read the next line as a continuation of the current
one. This backslash thing works inside triple-quoted
strings:

s = """A long string\
 not containing line breaks"""

print s

s = """A string
containing line breaks"""

print s

> Greetings
>
> Holger
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list