I have a simple best practice question. The setting is that i simply have one function calling another one. The code ist little dummy for better understanding:
def called_function(x):
y = x * 3
try:
z = 3 / x
except my_crazy_exception as e:
print("I want at least to know y!")
print(y)
# Does this make sense:
# ??? raise my_crazy_exception ????
if __name__ == "main":
for i in my_crazy_list:
try:
called_function(i)
except my_crazy_exception as e:
print("I want to know i!")
print(i)
Know i want to know information from the called function and as well from the calling function. So i want to pass the exception from the origin to the next higher function. My idea would be know just to raise another excepterin in the except:
part of the called function. But would this be best practice?
Aucun commentaire:
Enregistrer un commentaire