[Python-ideas] one line class definitions
Chris Rebert
pyideas at rebertia.com
Fri May 4 00:19:32 CEST 2012
On Thu, May 3, 2012 at 1:57 PM, nbv4 <nbvfour at gmail.com> wrote:
> Instead of
>
> class CustomException(Exception):
> pass
>
> how about just
>
> class CustomException(Exception)
>
> (no colon, no 'pass')
> I'm sure this has been suggested before, but I couldn't find any...
"Special cases aren't special enough to break the rules." -- PEP 20
Just use a docstring-only body; you should be documenting what the
exception means anyways:
class CustomException(Exception):
"""This exception means that a custom error happened."""
# other module-level code…
Cheers,
Chris
More information about the Python-ideas
mailing list