PEP8 compliance and exception messages ?

Ben Finney ben+python at benfinney.id.au
Mon Dec 6 00:21:26 EST 2010


shearichard <shearichard at gmail.com> writes:

> Hi - PEP8 says lines should not exceed 79 characters in length
> ( http://www.python.org/dev/peps/pep-0008/ ).
>
> So if you've got some code that looks like this :
>
> raise fooMod.fooException("Some message which is quite long")

PEP 8 also says those names are poorly chosen. Better:

    raise foomod.FooException("Some message which is quite long")

> raise fooMod.fooException("\
>         Some message \
>         which is quite long")

Take advantage of the parsing of string literals and parenthesis:

    raise foomod.FooException(
        "Some message"
        " which is quite long")

and for the sake of my eyes, avoid camelCase.



More information about the Python-list mailing list