6) c. Maximum Line Length

PEP 8 states that all lines should be limited to 79 characters.

1
2
3
4
5
def a_function(param1, param2, param3, param4, param5, param6, param7, param8):
    # This function's signature is exactly 79 characters long.
    # There is not a lot of space but it allows you to keep your code
    # clean and concise.
    pass

If you have a very long string or a piece of text in your code you can use the following syntax to wrap them. Please note that there are no commas after each string. If you put commas there it will no longer be a string but a tuple.

1
2
3
4
5
joke = (
    'Did you hear about the mathematician who is afraid of negative '
    'numbers? He will stop at nothing to avoid them.'
)
print(joke)
1
2
3
Output:
Did you hear about the mathematician who is afraid of negative numbers? He will
stop at nothing to avoid them.

Historically many devices could only display 80 characters per line. But even today this rule has its use. For example, it allows you to view several text files side by side. This is particularly useful when using code review tools.

This guideline is regularly debated among developers. Many believe that the rise of wide screen displays eliminates the need of such low character limit.

Some applications may not even allow you to follow this rule. It is up to you to decide the maximum length and stick to it.