Last active
August 29, 2015 14:13
-
-
Save agalera/aa10199ba96d0d4009c6 to your computer and use it in GitHub Desktop.
default values in python
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
#default values in ruby https://gist.github.com/kianxineki/8b13ebc8816623f4a650 | |
def append_values(new_value, a=[]): | |
a.append(new_value) | |
return a | |
append_values("n1") # result ['n1'] | |
rlist = append_values("n2") # result ['n1', 'n2'] | |
rlist.append("n3") | |
print(rlist) # result ['n1', 'n2', 'n3'] | |
append_values("n4") # result ['n1', 'n2', 'n3', 'n4'] | |
append_values("n0", []) # result ['n0'] | |
append_values("n5") # result ['n1', 'n2', 'n3', 'n5'] | |
append_values.func_defaults # (['n1', 'n2', 'n3', 'n5'],) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment