R
Roy Smith
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
else:
raise TypeError ('Unexpected keyword argument %s' % key)
which seems kind of verbose. Is there a neater way to do this check?
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
else:
raise TypeError ('Unexpected keyword argument %s' % key)
which seems kind of verbose. Is there a neater way to do this check?