On Wed, 03 Mar 2010 06:47:28 -0500, Oren Elrad wrote: > With that said, let me at least offer a token defense of my position. By > way of motivation, I wrote that email after copying/pasting the > following a few times around a project until I wrote it into def > SilentlyDelete() and its cousin SilentlyRmdir() > > """ code involving somefile """ > try: > ........os.remove(somefile) > except: > .......pass # The bloody search indexer has got the file and I can't > delete it. Nothing to be done.
Or: (1) you forgot to import the os module (2) the os module (or os.remove) was rebound or monkey-patched to something unexpected (3) you have a bug in your code and somefile=23 (say) instead of the filename you're expecting (4) the user hit the interrupt key just at that instance (5) somefile doesn't exist (6) somefile does exist, but you don't have write-permission for it (7) the disk is mounted read-only (8) you don't have a search indexer and something else has gone wrong Hiding all those different errors is, quite frankly, shoddy work. #1-3 certainly shouldn't be hidden, as they are bugs in your program. #4 shouldn't be hidden, ignoring the user's interrupt command is bad, and rude if it is deliberate. #5 probably shouldn't be hidden either, as it most likely indicates a program bug, but some rare applications may be okay with ignoring it. And #6-8 should be told to the user, so they can fix the problem. -- Steven -- http://mail.python.org/mailman/listinfo/python-list