Building a multiline string

lallous lallous at
Thu Feb 4 12:34:04 CET 2010


Maybe that's already documented, but it seems the parser accepts to
build a long string w/o really using the first method:

# Method1
x = "line1" + \ # cannot use comments!
"line2"+ \

and instead using a list with one element like this:

# Method2
x = [
"line1" # can use comments

# Method3
x = (
"line1" # can use comments

(Not that I don't want new lines in the strings)

Now should I be using method 2 or 3 in production code?


More information about the Python-list mailing list