Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear, but not very pretty solution in Clear category for Compare Functions by kkkkk
def checkio(f, g):
def h(*args, **kwargs):
def tryme(func, *args, **kwargs):
error = False
result = None
try:
result = func(*args, **kwargs)
if result == None:
error = True
except:
error = True
return (result, error)
f_result, f_error = tryme(f, *args, **kwargs)
g_result, g_error = tryme(g, *args, **kwargs)
result = None
if f_result != None:
result = f_result
elif g_result != None:
result = g_result
status_string = ""
if not f_error and not g_error:
if f_result == g_result:
status_string = "same"
else:
status_string = "different"
else:
if f_result == None and g_result != None:
status_string = "f_error"
elif f_result != None and g_result == None:
status_string = "g_error"
else:
status_string = "both_error"
return (result, status_string)
return h
Sept. 19, 2020