[Tutor] continuation lines

Kent Johnson kent_johnson at skillsoft.com
Mon Nov 1 23:19:27 CET 2004

At 01:36 PM 11/1/2004 -0800, Marilyn Davis wrote:
>And another thing, when, in Python code, can I hit the return key
>mid-statement?  After a ',', and when else?  I've sort of given up
>trying to break up statements.

You can break a line whenever you have an open parenthesis (, brace { or 
bracket [

lst = [

myDict = {
   'a' : 1,
   'b' : 2

callOfFunctionWithVeryManyArguments('arg1', 'arg2',
     'arg3', 'arg4')

You can explicitly continue a line by ending it with a \
x = a + \

You can include line breaks inside triple-quoted strings:
s = '''Here is some text
that spans two lines'''


More information about the Tutor mailing list