I have a function name "is_target_line(line)", this function is validate each line that I read in the txt file, and I am thinking what is the best practice to raise the Error.
def is_target_line(line:str):
if 'specific_string' in line:
return True
else:
return False
Python will not check if line is str or not, so I will add a logic to raise the error like this.
def is_target_line(line:str):
if type(line) != str:
raise TypeError
if 'specific_string' in line:
return True
else:
return False
My question is, should I add this logic control to raise the Error for checking type, or just let the python interpreter to raise the Error in run time, and what is the good practice of throwing error ?