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
I would make a couple suggestions before answering your question as it may answer the question for you.
latestpdf means very little to anyone but looking over your function latestpdf() gets the latest pdf. I would suggest that you name it getLatestPdfFromFolder(folder).As soon as I did this it became clear what it should return.. If there isn't a pdf raise an exception. But wait there more..
for folder in folders:
try:
latest = getLatestPdfFromFolder(folder)
results = somefuc(latest)
except IOError: pass
Hope this helps!