Last active
November 7, 2015 21:31
-
-
Save nicoddemus/3d24094cfb553989712a to your computer and use it in GitHub Desktop.
Handling keyword arguments default values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python 2 | |
def foo(**kwargs): | |
x = kwargs.pop('x', 10) | |
y = kwargs.pop('y', 'no value') | |
if kwargs: | |
raise TypeError('unknown keyword arguments: %s' % kwargs.keys()) | |
print x, y | |
# python 3 | |
def foo(*, x=10, y='no value'): | |
print(x, y) |
hackebrot
commented
Nov 7, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment