[Python-ideas] __missing__ object/keyword

Greg Falcon veloso at verylowsodium.com
Thu Nov 6 21:47:33 CET 2008

On Thu, Nov 6, 2008 at 3:31 PM, George Sakkis <george.sakkis at gmail.com> wrote:
> Several times I find myself using the following idiom:
> _Missing = object()   # sentinel
> def foo(x, y=_Missing):
>   if y is _Missing:
>     do_this
>   else:
>     do_that

> It would be nice if a new object or keyword, say __missing__, was
> introduced as a canonical way to address this common scenario.

> Thoughts ?

This has been proposed and shot down before:


The older proposal didn't give __missing__ the special run-time and
compile-time error behaviors, but this actually just makes things
worse.  Why complicate the language merely to save a single idiomatic
line of code dealing with a relatively infrequent use-case?

Greg F

More information about the Python-ideas mailing list