Trying to write comments after escaping newline
Diez B. Roggisch
deetsNOSPAM at web.de
Tue Apr 27 14:50:44 EDT 2004
p brian wrote:
> mystring = "hello " + someVariable + \
> "multiple lines 4 clarity" + \
> someothervariable
>
> The above works , but if I add comments
>
> mystring = "hello " + someVariable + \ #comment
> "multiple lines 4 clarity" + \ #comment
> someothervariable #comment
>
> it stops working because instead of escaping a newline I am now just
> escaping a space or tab.
> Is there some clever thing i have missed?
To make line continuation work, the newline at the end of an line has to be
escaped using an \ - and putting your comment there makes this exactly what
you already observed: a space or tab escape instead of the newline.
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list