Skip to content

Instantly share code, notes, and snippets.

@micolous
Last active December 10, 2015 20:58
Show Gist options
  • Save micolous/4491315 to your computer and use it in GitHub Desktop.
Save micolous/4491315 to your computer and use it in GitHub Desktop.
null kwargs strangeness
#!/usr/bin/env python
def some_operation(foo=0):
print ("foo is %r" % foo)
def kwargs_print(**kwargs):
print ("you gave me %r" % kwargs)
a = {}
kwargs_print(**a)
some_operation(**a)
a = {'foo': 1}
kwargs_print(**a)
some_operation(**a)
a = {'foo\0bar': 2}
kwargs_print(**a)
some_operation(**a)
# on py2.7.2, throws:
# TypeError: some_operation() got an unexpected keyword argument 'foo'
# on py3.3.0, throws:
# TypeError: some_operation() got an unexpected keyword argument 'foo bar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment