Multiline strings and indentation

jvickroy at sec.noaa.gov.bbs jvickroy at sec.noaa.gov.bbs
Mon Jul 17 16:50:04 EDT 2000


How about:

>>> print "this" + \
                " is" + \
                " a" + \
                " long" + \
                " string"

this is a long string
>>>

"donotspam-jen at personic.com" wrote:

> I'm just getting started with Python. The indentation feature really does
> make things readable ... except when using multi-line strings.  This just
> doesn't look right:
>
> def multiline(x):
>   if x:
>     print """this is a
> multi-line string that spans
> three lines"""
>  print "another string"
>
> Is there a way to make the above more readable? It would be nice if it could
> be written this way and have Python just figure out what whitespace to
> ignore:
>
> def multiline(x):
>   if x:
>     print """this is a
>              multi-line string that spans
>              three lines"""
>  print "another string"
>
> Thanks for any suggestions!
>
> Jen



More information about the Python-list mailing list