In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: >Aahz <[EMAIL PROTECTED]> wrote: >>Alex: >>>Aahz: >>>>Alex: >>>>> >>>>>the canonical idiom when you need such distinction is: >>>>> >>>>>_not_there = object() >>>> >>>> What's your preferred idiom when you're dealing with storable objects? >>> >>>What's a "storable object"? You mean, something that can be pickled, or >>>passed to the .write method of a file object, or stored in a database, >>>or what else? >> >> Pickled and/or stored in a DB. > >Relational databases have the concept of NULL specifically to indicate >"there is NOTHING here". I love it.
Right. >For pickling, object() as a unique "nothing here, NOT EVEN a None" >marker (AKA sentinel) works fine. How does that work? Maybe I'm missing something obvious. sentinel = object() class C: def __init__(self, foo=sentinel): self.foo = foo def process(self): if self.foo is not sentinel: .... Now, the way I understand this, when your application restarts and an instance of C is read from a pickle, your sentinel is going to be a different instance of object() and process() will no longer work correctly. Are you suggesting that you need to pickle the sentinel with the instance? Or is there some other trick I'm missing? -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." --Red Adair -- http://mail.python.org/mailman/listinfo/python-list