Pythonic way of returning and checking method execution
I am currently using golang style of coding in python code, decided to move pythonic way
example:
import sys
from typing import Union, Tuple
def get_int_list(list_data: list) -> Tuple[Union[list, None], bool]:
try:
return [int(element) for element in list_data], True
except ValueError:
print("Failed to convert int elements list")
return None, False
my_list = ["1", "2", "a"]
int_list, status = get_int_list(my_list)
if not status:
sys.exit(1)
sys.exit(0)
I read in python docs pythonic way of doing is raising exceptions.
Can anyone provide me example for above method?