Reputation: 105
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.
Example 1
self.remote_conn_pre.connect("self.hostname, "
"username=self.username, password=self.password, "
"look_for_keys=False, allow_agent=False")
Example 2
self.remote_conn.send(""create bigdata\n" "
" .format(pending.upper(), (total) + 9)")
Example 3
print ("This is the first line of my text {} "
"which will be joined to a second {}.".format(a,b))
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
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
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