On Jan 21, 10:09 am, [EMAIL PROTECTED] wrote: > > Grab(argdict, key, default) is argdict.pop(key, default) > > "pop() raises a KeyError when no default value is given and the key is > not found."
And it doesn't if a default is provided, which is always the case in the uses of Grab(...), so it seems the right tool for the job. > > def grab(kw, key, default=None): > > try: > > return kw.pop(key) > > except KeyError: > > return default > > So Bruno's technique seems to me to be the correct one as it catches > the KeyError. If you really really want to write a grab function (IMHO pop is good enough): def grab(kw, key, default=None): return kw.pop(key, default) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list