[Python-ideas] Add new `Symbol` type

Barry Warsaw barry at python.org
Tue Jul 10 16:53:51 EDT 2018


Guido van Rossum wrote on 7/6/18 08:31:
> Thanks for an interesting discussion. I would also urge people to limit the
> use of such sentinels for cases where it is *really* important to
> distinguish between, say, f(None) and f(). In most cases using def
> f(arg=None) is fine, and often it is even a virtue that passing None or
> omitting an argument has exactly the same meaning. (I do know there a cases
> where this doesn't apply -- I just think they ought to be fairly unusual.)

One of the most common places I use a non-None sentinel is when None is 
a valid value in a dictionary:

_missing = object()

if mydict.get('foo', _missing) is _missing:
      # it ain't there

I generally don't feel like a more complicated repr is valuable here, so 
I haven't really wanted a built-in sentinel in a long time.  My search 
fu is weak today, but I'm pretty sure I suggested such a thing (and was 
rightly persuaded against it) many years ago.

what-goes-around-comes-around-ly y'rs,
-Barry




More information about the Python-ideas mailing list