Checking for invalid keyword arguments?
roy at panix.com
Sun Sep 28 23:06:11 CEST 2003
I've got a function that takes a couple of optional keyword arguments.
I want to check to make sure I didn't get passed an argument I didn't
expect. Right now I'm doing:
conversion = None
drop = False
for key, value in kwArgs.items():
if key == 'conversion':
conversion = value
elif key == 'drop':
drop = value
raise TypeError ('Unexpected keyword argument %s' % key)
which seems kind of verbose. Is there a neater way to do this check?
More information about the Python-list