What\'s better practice in a user-defined function in Python: raise an exception or return None? For example, I have a function that finds the mos
raise
return None
with python 3.5's typing:
example function when returning None will be:
def latestpdf(folder: str) -> Union[str, None]
and when raising an exception will be:
def latestpdf(folder: str) -> str
option 2 seem more readable and pythonic
(+option to add comment to exception as stated earlier.)