Continuation ( ) escape character Python

Python statements are, in general, delimited by NEWLINEs, meaning one statement per line. Single statements can be broken up into multiple lines by use of the backslash. The backslash symbol ( ) can be placed before a NEWLINE to continue the current statement onto the next line.


>>> if(1==1) and 
    print 'everything all right'

everything all right

There are two exceptions where lines can be continued without backslashes. A single statement can take up more than one line when (1) container objects are broken up between elements over multiple lines, and when (2) NEWLINEs are contained in strings enclosed in triple quotes.


>>> print ''' the quick brown red
fox jumps over
the lazy dog'''
 the quick brown red
fox jumps over
the lazy dog

You may also like...