[EMAIL PROTECTED] a écrit :
>> 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."

Then use it with a default value !-)

>> 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.

Note that I cancelled the message (too bad, doesn't work everywhere). I 
totally agree with Arnaud on this, and should sometimes re-read the doc 
for stuff I use so often I think I know them.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to