24 Jul
2018
24 Jul
'18
12:51 a.m.
On Jul 23, 2018 8:43 PM, "Chris Barker - NOAA Federal via Python-ideas" < python-ideas@python.org> wrote:
Procedures return None ==================
a = [3,1,2] b = a.sort() a, b ([1, 2, 3], None)
This is less about None than about the convention that mutating methods return None. Maybe that discussion belongs elsewhere.
None is default return value =====================
def fn(): pass ... fn() # No response! print(fn()) # Here's why. None
Yup. I believe these two are related and an artifact of how code/function objects always leave *something* on TOS/top-of-stack. IIRC even module objects have a discarded "return value" (in CPython at least). This internal, unseen, and very-much-special-syntax-worthy value, is None other. -- C Anthony