["python","exception"]
Raise exception vs. return None in functions?

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 most recent file in a folder. def latestpdf(folder): # list the files and sort them try: latest = files[-1] except IndexError: # Folder is empty. return None # One possibility raise FileNotFoundError() # Alternative else: return somefunc(latest) # In my case, somefunc parses the filename Another option is leave the exception and handle it in the caller code, but I figure it's more clear to deal with a FileNotFoundError than an IndexError. Or is it bad form to re-raise an exception with a different name?
It's really a matter of semantics. What does foo = latestpdf(d) mean? Is it perfectly reasonable that there's no latest file? Then sure, just return None. Are you expecting to always find a latest file? Raise an exception. And yes, re-raising a more appropriate exception is fine. If this is just a general function that's supposed to apply to any directory, I'd do the former and return None. If the directory is, e.g., meant to be a specific data directory that contains an application's known set of files, I'd raise an exception.