code: def expand_source_files(filenames, cwd=None):
      out = []
      for f in expand_paths(filenames, cwd):
          if os.path.isdir(f):
              out += collect_files(f, ".py")
          else:
              if f.endswith(".py"):
                  out.append(f)
      return sorted(set(out))