[FEEDBACK] Is this script efficient...is there a better way?

Matt Gerrans mgerrans at mindspring.com
Tue Sep 17 02:34:25 EDT 2002


Well, since every other aspect of this little script has been beaten to
death, I'll add my 2.0*pow(10,-17) Kongbucks on the error messages: I make a
habit of including as much useful context information as I can, so for
instance, instead of:
...
except:
   print 'Failed to open log file.'

I might have something like:
...
except:
   print 'Failed to open %s for output.' % logFileName

This usually makes me a lot happier when the silly thing does fail (and
especially when someone else is using the script and I discover that they
don't have access to the same network resource I do, or don't have the same
configuration, etc.).   The traceback module is handy if you want to display
even more information from the exception.

- Matt







More information about the Python-list mailing list