I would like to ask what's the best/idioms way in python to handle this type of code logic.
list_a = []
def func_a():
if some check not pass
return False
# check pass
add some stuff to list_a and return True
def func_b():
if some check not pass
return False
# check pass
add some stuff to list_a and return True
def func_c():
if some check not pass
return False
# check pass
add some stuff to list_a and return True
def apply_function():
if fun_a():
return list_a
if fun_b():
return list_a
if fun_c():
return list_a
...
return list_a #empty list
If there are more than 10 functions need to check in apply_function()
, is there any better way to handle?
This maybe work for me
If funcA() or funcB() or funcC():
return list_a
return list_a
Does any()
can be use in this situation?
Thanks.
Aucun commentaire:
Enregistrer un commentaire