kitty
kitty

Reputation: 105

How to add line breaks to prevent overly long lines?

I just read the best practices of Python scripts. I found recommended length should not exceed 80 characters per line.

So in my script more than 100 characters are exist.

I have break the lines and below are examples.

Could any one please correct me if I am doing anything wrong and help me determine the best ways to break long lines into small lines.

Upvotes: 0

Views: 96

Answers (2)

Dillanm
Dillanm

Reputation: 866

Python supports splitting up lines using the backslash \ character, like so:

d = "one two three " \
    "four five six"

print d

Prints one two three four five six

Upvotes: 0

Oluwafemi Sule
Oluwafemi Sule

Reputation: 38982

You can use docstrings and escape the newline character.

print ("""
This is the first line of my text {} \
which will be joined to a second {}.
""").format(a,b)

Upvotes: 2

Related Questions