This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients SnoopJeDi, barry, docs@python, eric.araujo, steven.daprano, terry.reedy
Date 2022-01-07.22:23:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Barry: The PEP 8 'return None' recommendation could be added to the Reference entry for 'return'.  But I think this should be a separate issue as 1) it is about coding rather than documentation and 2) there is the possible objection that choosing completely explicit 'return None' versus half explicit, half implicit 'return' and the latter versus completely implicit <nothing at end> should be left to the style PEP.

I do think it's a question of style.  Section 7.6 of the language reference says:

> If an expression list is present, it is evaluated, else None is substituted.

which is the important concept that beginners should learn.

I agree that the admonition in PEP 8 is really trying to say "don't mix implicit and explicit return styles".  Implicit None return is fine if all exit paths are implicit.  But once you add an explicit value to a return path, all return paths should use explicit values, including those that return None.

IME, while I do occasionally encounter push back on this when doing reviews, most folks come around to this p.o.v.
Date User Action Args
2022-01-07 22:23:15barrysetrecipients: + barry, terry.reedy, eric.araujo, steven.daprano, docs@python, SnoopJeDi
2022-01-07 22:23:15barrysetmessageid: <>
2022-01-07 22:23:15barrylinkissue46282 messages
2022-01-07 22:23:15barrycreate