Wrap long lines in Python [duplicate]

How do I wrap long lines in Python without sacrificing indentation?

For example:

def fun():
    print '{0} Here is a really long sentence with {1}'.format(3, 5)

Suppose this goes over the 79 character recommended limit. The way I read it, here is how to indent it:

def fun():
    print '{0} Here is a really long \
sentence with {1}'.format(3, 5)

However, with this approach, the indentation of the continued line matches the indentation of the fun(). This looks kinda ugly. If someone was to go through my code, it would look bad to have uneven indentation because of this print statement.

How do I indent lines like this effectively without sacrificing code readability?

6 Answers
6

Leave a Comment