[ZODB-Dev] BTree.setdefault(), BTree.pop()

Jeremy Hylton jhylton at gmail.com
Mon Oct 4 14:42:08 EDT 2004


On Mon, 4 Oct 2004 19:25:54 +0200, Dieter Maurer <dieter at handshake.de> wrote:
> Tim Peters wrote at 2004-10-4 11:45 -0400:
> > ...
> >    pl = t.get(key)
> >    if pl is None:
> >        pl = t[key] = PersistentList()
> >    pl.append(value)
> >
> >So I'm -0 on the idea, because I doubt it will be used.  I understand that
> >you think you'll use it.  Anyone else?
> 
> I avoid "setdefault" almost always.

I've written some code using setdefault() recently, but I'm not
satisfied with it.  There was a thread on python-dev several months
ago where someone suggested a way to provide a factory for default
values.  That seems like a cleaner API if you were going to add this
feature.

Jeremy


More information about the ZODB-Dev mailing list