def is_readable(path):
 if os.path.isdir(path):
  try:
   os.listdir(path)
  except (OSError, IOError):
   return False
 else:
  try:
   with _open(path, 'r') as fd:
    pass
  except (OSError, IOError):
   return False
 return True

def is_readable ( path ) : if os . path . isdir ( path ) : try : os . listdir ( path ) except ( OSError , IOError ) : return False else : try : with _open ( path , 'r' ) as fd : pass except ( OSError , IOError ) : return False return True
check if a given path is readable by the current user .