def _listdir(root):
 res = []
 root = os.path.expanduser(root)
 try:
  for name in os.listdir(root):
   path = os.path.join(root, name)
   if os.path.isdir(path):
    name += os.sep
   res.append(name)
 except:
  pass
 return res

def _listdir ( root ) : res = [ ] root = os . path . expanduser ( root ) try : for name in os . listdir ( root ) : path = os . path . join ( root , name ) if os . path . isdir ( path ) : name += os . sep res . append ( name ) except : pass return res
list directory root appending the path separator to subdirs .