Python Forum

Full Version: long lines, longer than 72 or 79
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i'm cleaning up a lot of code, including trying to make it fit in 72 columns, or at least in 79 columns.  most things are going ok.  a few things are being difficult.  is there any general scheme for making long code lines fit well?

i have these right now:

        raise TypeError('Not a number passed to unmod() arg2: %s (modulus)' % repr(m))
        raise TypeError('Not a number passed to unmod() arg1: %s (value)' % repr(n))
        raise ValueError('Negative value passed to unmod() arg2: %s (modulus)' % repr(m))
what is a good way to split the long lines and keep things readable?  is there a better (and hopefully shorter) way to code them?  they are separate lines.
One way

raise TypeError(
        'Not a number passed to unmod() arg2: %s (modulus)' % repr(m))
raise TypeError(
        'Not a number passed to unmod() arg1: %s (value)'
        % repr(n)
raise ValueError('Negative value passed to unmod() arg2: %s (modulus)'
        % repr(m))
Some statements like with may need \. According to pep 8

Some examples here and in the next three chapters there are more