split long string in two code lines

Terry Reedy tjreedy at udel.edu
Mon Jun 13 23:55:31 EDT 2011


On 6/13/2011 5:51 PM, darnold wrote:
> print "this" \
>      " is" \
>      " a" \
>      " test" \
> this is a test

 >>> print('this'
       ' is'
       ' a'
       ' test')
this is a test

Python ignores \n within parentheses, brackets, and braces, so no 
fragile trailing backslash needed. ('Fragile', because invisible space 
or tab after '\' is an error.)

-- 
Terry Jan Reedy




More information about the Python-list mailing list