[Python-ideas] Optional parameters without default value

Mike Miller python-ideas at mgmiller.net
Fri Mar 3 00:13:12 EST 2017


Agreed, I've rarely found a need for a "second None" or sentinel either, but 
once every few years I do.  So, this use case doesn't seem to be common enough 
to devote special syntax or a keyword to from my perspective.

But, I'll let you know my secret.  I don't make my own sentinel, but rather use 
another singleton that is built-in already.  And if you squint just right, it 
even makes sense.

It is a built-in singleton so rarely known that you will almost never encounter 
code with it, so you'll have it all to yourself.  Even on a python mailing list, 
in a thread about sentinels/singletons, it will not be mentioned.  Some may 
"consider it unnatural."  It is…

…

… (hint)

… (wait for it)

…

 >>> Ellipsis
Ellipsis


Don't think I've ever needed a "third None" but if I did I'd probably try an 
enum instead.

-Mike



On 2017-03-02 15:02, Barry Warsaw wrote:
> On Mar 02, 2017, at 06:37 PM, Brett Cannon wrote:
>
>> So to me, there's actually two things being discussed. Do we need another
>> sentinel to handle the "None is valid" case, and do we want syntax to more
>> clearly delineate optional arguments?
>
> No, and no (IMHO).
>
> -Barry
>


More information about the Python-ideas mailing list