assigning multi-line strings to variables

Brendan Abel 007brendan at gmail.com
Tue Apr 27 22:31:15 EDT 2010


On Apr 27, 7:20 pm, goldtech <goldt... at worldpost.com> wrote:
> Hi,
>
> This is undoubtedly a newbie question. How doI assign variables
> multiline strings? If I try this i get what's cited below. Thanks.
>
> >>> d="ddddd
> ddddd"
> >>> d
>
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in <module>
> NameError: name 'd' is not defined



d = "ddddddddd"\
    "ddddd"

or

d = "dddddddddd\
dddddd"

You don't need the trailing slash in the first example if you are
writing this in a script, python assumes it.



More information about the Python-list mailing list