style question
Fredrik Lundh
fredrik at pythonware.com
Mon Jun 26 05:47:21 EDT 2006
Frank Millman wrote:
>> How about
>>
>> message = ("This is line1. "
>> "This is line2 "
>> "This is line3\n")
>>
>> The brackets mean that the lines are automatically treated as
>> continuous, without the need for the ugly '\' continuation character.
>>
>> The opening/closing quotes on each line mean that the strings are
>> contatenated into one long string.
>
> Don't know what happened there - Google seems to have messed up my
> indentation.
>
> My intention was that each of the three leading quote marks line up
> vertically, but when I read it back via Google Groups, the second two
> lines were pushed over to the right.
assuming fixed-pitch fonts isn't very Pythonic, though; to get reliable indentation
no matter what font you're using, you can write:
message = (
"This is line1. "
"This is line2 "
"This is line3\n")
whether this is better than """ depends on the situation.
</F>
More information about the Python-list
mailing list