Last active
May 26, 2025 15:33
-
-
Save antonioshadji/eb416ce60426e1faac66b89cc211a883 to your computer and use it in GitHub Desktop.
test of python default argument definition and the results
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
def func(x=[]): | |
x.append(1) | |
return x | |
print(func()) | |
print(func()) | |
print(func([2])) | |
print(func()) | |
# above code show that default parameter is defined exactly once when function in defined | |
# x the default parameter still exists, but is unused if a parameter is given to the function | |
# https://img.leroscapital.com/python-default-parameter-definition.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment