Last active
May 14, 2019 02:13
-
-
Save hashlash/0df4550ebe1055ea4416cadd6baf3607 to your computer and use it in GitHub Desktop.
Simple example for using asterisks for unpacking variables
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
# function with keyworded parameter | |
def func2(var1=None, var2=None, var3=None): | |
print(var1, var2, var3) | |
# both function call are the identical | |
func2(var1='hello', var2='world', var3='!') | |
func2(**{'var1':'hello', 'var2':'world', 'var3':'!'}) | |
# this one throw error | |
func2(**{'var1':'hello', 'var2':'world', 'var4':'!'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment