[Python-ideas] [Python-Dev] nodef

Arnaud Delobelle arno at marooned.org.uk
Sat May 26 21:30:35 CEST 2007


On 24 May 2007, at 15:42, Martin Blais wrote:

> 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".

Just as you find that 'None' is sometimes a valid value for a  
function parameter (and this is the reason why you would like  
'nodef'), if there was a 'nodef' builtin you would sometimes find  
that it is a meaningful value for a function parameter.  Would you  
then advocate the creation of a 'really_nodef' builtin? And then a  
'this_time_i_really_mean_it_nodef' builtin?

This is why a 'nodef' keyword is not a good idea. 'None' is useful  
because often you expect an argument of a certain type (e.g. a list,  
so you know it should not be 'None').

-- 
Arnaud





More information about the Python-ideas mailing list