[Python-Dev] PEP 8 update
Barry Warsaw
barry at python.org
Tue Apr 7 03:31:33 CEST 2015
On Apr 06, 2015, at 06:08 PM, Guido van Rossum wrote:
>I've taken the liberty of adding the following old but good rule to PEP 8
>(I was surprised to find it wasn't already there since I've lived by this
>for ages):
>
> Be consistent in return statements. Either all return statements in a
> function should return an expression, or none of them should. If any return
> statement returns an expression, any return statements where no value is
> returned should explicitly state this as return None, and an explicit
> return statement should be present at the end of the function (if
> reachable).
+1
Odd synchronicity: Today I discovered an old interface that was documented as
returning a "thing or None" but the latter was relying on implicit None return
in some cases. Fixed of course in exactly the way PEP 8 now recommends. :)
Cheers,
-Barry
More information about the Python-Dev
mailing list