Skip to content

Instantly share code, notes, and snippets.

@mansam
Last active August 29, 2015 14:24
Show Gist options
  • Save mansam/4e8cca8ae3f8b187a039 to your computer and use it in GitHub Desktop.
Save mansam/4e8cca8ae3f8b187a039 to your computer and use it in GitHub Desktop.
>>> def by_id(id, **kwargs):
... print(id, kwargs)
...
>>> by_id({'id': 1, 'foobaz': 2, 'bazfoo': 3})
{'foobaz': 2, 'bazfoo': 3, 'id': 1} {}
>>> by_id(**{'id': 1, 'foobaz': 2, 'bazfoo': 3})
1 {'foobaz': 2, 'bazfoo': 3}
>>> by_id(1, **{'id': 1, 'foobaz': 2, 'bazfoo': 3})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: by_id() got multiple values for argument 'id'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment