Last active
December 18, 2015 01:18
-
-
Save fnielsen/5702632 to your computer and use it in GitHub Desktop.
Python evaluation of default arguments
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 func1(f1=None): | |
print("In func1a") | |
return f1 | |
def func2(f2=func1): | |
print("In func2a") | |
return f2() | |
def func1(f1=func2): | |
print("In func1b") | |
return f1() | |
def func2(f2=func1): | |
print("In func2b") | |
return f2() | |
func1() | |
def func3(): | |
print("In func3a") | |
return None | |
def func4(): | |
print("In func4a") | |
return func3() | |
def func3(): | |
print("In func4b") | |
return func4() | |
# func3() # Yes, it is still possible to call the functions recursively |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment