def isdir(path):
 try:
  st = os.stat(path)
 except os.error:
  return False
 return stat.S_ISDIR(st.st_mode)

def isdir ( path ) : try : st = os . stat ( path ) except os . error : return False return stat . S_ISDIR ( st . st_mode )
return true if the pathname refers to an existing directory .