Barry A. Warsaw <ba...@python.org> added the comment:

> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46282>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to