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


_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to