Skip to content

Instantly share code, notes, and snippets.

@fnielsen
Last active December 18, 2015 01:18
Show Gist options
  • Save fnielsen/5702632 to your computer and use it in GitHub Desktop.
Save fnielsen/5702632 to your computer and use it in GitHub Desktop.
Python evaluation of default arguments
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