[Python-Dev] redefining is (original) (raw)

Barry Warsaw barry at python.org
Thu Mar 18 10:50:11 EST 2004


On Thu, 2004-03-18 at 10:23, Jewett, Jim J wrote:

There is an idiom (I've seen it more in Lisp than in python) of creating a fresh object to act as a sentinel.

A very common use case in Python is where None is a valid value in a dictionary:

missing = object()

if d.get('somekey', missing) is missing:

it ain't there

It even reads well!

-Barry



More information about the Python-Dev mailing list