Multiline code - trailing slash usage

Christoph Haas email at christoph-haas.de
Thu Mar 15 16:15:42 CET 2007


On Thursday 15 March 2007 15:57, abcd wrote:
> When do I need to use a trailing slash to separate code over multiple
> lines.
>
> For example:
>
> x = "hello world, this is my multiline " + \
>      "string!!!!"

Needed. Although you can omit the "+".

> x = {'name' : \
>       'bob'}

Not needed because you are inside the curly brackets {} and it's clear 
where the statement ends.

> Do I need to use the "\" in the above examples?  When do i need to use
> it?

Cheers
 Christoph



More information about the Python-list mailing list