Ah! nice, thanks, knew I was probably missing something. On Jan 19, 2008 5:01 PM, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Jan 19, 11:02pm, "David Tweet" <[EMAIL PROTECTED]> wrote: > > > def Grab(argdict, key, default): > > """Like argdict.get(key, default), but also deletes key from argdict.""" > > if key in argdict: > > retval = argdict["key"] > > del(argdict[key]) > > else: > > retval = default > > return retval > > > > Dictionaries already have a method for this. It's called pop. It's a > good idea to have a look at methods of builtin types before > reimplementing the wheel! > > Grab(argdict, key, default) is argdict.pop(key, default) > > -- > Arnaud > > > -- > http://mail.python.org/mailman/listinfo/python-list >
-- -David -- http://mail.python.org/mailman/listinfo/python-list