Last active
August 29, 2015 14:26
-
-
Save hannal/84a91e9a05287fbdb1b6 to your computer and use it in GitHub Desktop.
This file contains 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
c_num = 10 | |
d_num = 0 | |
def do_something(a, b, c=0, d=0): | |
return a + b + c + d | |
if d_num > 0: | |
print(do_something(1, 2, c=c_num, d=d_num)) | |
else: | |
print(do_something(1, 2, c=c_num)) | |
################################## | |
unpack = {} | |
unpack['c'] = 10 | |
if d_num > 0: | |
unpack['d'] = d_num | |
print(do_something(1, 2, **unpack)) | |
################################## | |
# in Python 3 | |
def do_something3(a, b, *, c=0, d=0): | |
return a + b + c + d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment