Can anyone comment as to whether this is good style:

try:
  f=open(fname,'rb').read()
except:
  ... error message ...

------- vs. ---------

import os.path
if os.path.isfile(fname):
  f=open(fname,'rb').read()
else:
  ... error message ...


I much prefer the first example because it's so much easier and quite
robust. I figure I still have to do the try when opening the file,
even in the 2nd case. Am I paying a performance penalty for having my
cake and eating it?

Reply via email to