
On Thu, Nov 6, 2008 at 3:47 PM, Greg Falcon <veloso@verylowsodium.com>wrote: On Thu, Nov 6, 2008 at 3:31 PM, George Sakkis <george.sakkis@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:
http://mail.python.org/pipermail/python-dev/2007-May/073439.html
The older proposal didn't give __missing__ the special run-time and compile-time error behaviors,
I agree that it doesn't make sense without special compile/runtime behavior; that would be like adding a second None.
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?
I can't tell how much it would complicate the implementation of the language but the semantics are pretty straightforward. But you have a point there, None is more often than not an adequare sentinel, so if implementing __missing__ requires significant work it's probably not worth the effort. George