Skip to content

Instantly share code, notes, and snippets.

@JoMingyu
Last active March 31, 2018 12:32
def calculator(fn=None, a=0, b=0):
def sum():
return a + b
if fn:
return fn(a, b)
else:
return sum()
print(calculator(lambda a, b: a - b, 1, 3))
# -2
print(calculator(a=1, b=3))
# 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment