I have written a function f(x) that either returns a dictionary or an error message.
def myfunc():
try:
return dictionary
except BaseException as e:
return e
return_value = myfunc()
if return_value a dictionary:
do this
else:
do that
I need to detect the type of return in another function f(y) which calls f(x).
How do I do that?
thanks in advance
try ... catchoutsidemyfunc(), since on error the function will pass the exception to the caller.myfunc().returnan exception instance. You should just let it be raised. That's the point of how exceptions work.