None versus MISSING sentinel -- request for design feedback

Chris Angelico rosuav at
Fri Jul 15 02:08:41 EDT 2011

On Fri, Jul 15, 2011 at 3:28 PM, Steven D'Aprano
<steve+comp.lang.python at> wrote:
> My question is, should I accept None as the missing value, or a dedicated
> singleton?
> In favour of None: it's already there, no extra code required. People may
> expect it to work.
> Against None: it's too easy to mistakenly add None to a data set by mistake,
> because functions return None by default.

I guess the question is: Why are the missing values there? If they're
there because some function returned None because it didn't have a
value to return, and therefore it's a missing value, then using None
as "missing" would make a lot of sense. But if it's a more explicit
concept of "here's a table of values, and the user said that this one
doesn't exist", it'd be better to have an explicit MISSING. (Which I
assume would be exposed as yourmodule.MISSING or something.)

Agreed that float('nan') and "" and "spam" are all bad values for
Missings. Possibly "" should come out as 0, but "spam" should
definitely fail.

Chris Angelico

More information about the Python-list mailing list