def open_if_exists(filename, mode='rb'):
 try:
  return open(filename, mode)
 except IOError as e:
  if (e.errno not in (errno.ENOENT, errno.EISDIR)):
   raise

def open_if_exists ( filename , mode = 'rb' ) : try : return open ( filename , mode ) except IOError as e : if ( e . errno not in ( errno . ENOENT , errno . EISDIR ) ) : raise
returns a file descriptor for the filename if that file exists .