1logf = open("download.log", "w")
2for download in download_list:
3 try:
4 # code to process download here
5 except Exception as e: # most generic exception you can catch
6 logf.write("Failed to download {0}: {1}\n".format(str(download), str(e)))
7 # optional: delete local version of failed download
8 finally:
9 # optional clean up code
10 pass
11