code: def expand_path(path):
      
  
      paths = []
      path = os.path.expanduser(path)
      path = os.path.expandvars(path)
  
      if os.path.isdir(path):
  
          for (dir, dirs, files) in os.walk(path):
              for file in files:
                  paths.append(os.path.join(dir, file))
      else:
          paths.extend(glob(path))
  
      return paths
docs: Expands directories and globs in given path.