[Python-ideas] [Python-Dev] nodef
Martin Blais
blais at furius.ca
Thu May 24 16:42:34 CEST 2007
On 5/23/07, Collin Winter <collinw at gmail.com> wrote:
> [moving to python-ideas, where it belongs]
>
> > I think Python needs a builtin for this very purpose. I propose
> > 'nodef', a unique object whose sole purpose is to serve as a default
> > value. It should be unique, in the same sense that 'None' is unique.
>
> I've run into this situation several times before, and I've never felt
> that defining my own sentinel was unduly taxing. Having a built-in
> would only save a single line, the initial "sentinel = object()".
There is another benefit to a builtin 'nodef', BTW, which is that of a
consistent meaning for the word. Having a consistent name for this
concept--across all programs, if it were in the language--makes it
more obvious what you're trying to achieve. Otherwise, you decide to
use 'sentinel', I choose 'NoDef', Barry uses 'missing', and we're all
speaking a different "language".
Thought I do admit that the possibility of misuse of a builtin 'nodef'
is slightly troubling. I guess object() is our (gensym), I did not
know that.
cheers,
More information about the Python-ideas
mailing list