def isfile(path):
 try:
  st = os.stat(path)
 except OSError:
  return False
 return stat.S_ISREG(st.st_mode)

def isfile ( path ) : try : st = os . stat ( path ) except OSError : return False return stat . S_ISREG ( st . st_mode )
test whether a path is a file .