Skip to content

Instantly share code, notes, and snippets.

@jgs03177
Created January 23, 2024 10:39
Show Gist options
  • Save jgs03177/6b6153571a490e33d3e113e262dbab45 to your computer and use it in GitHub Desktop.
Save jgs03177/6b6153571a490e33d3e113e262dbab45 to your computer and use it in GitHub Desktop.
Code amalgamation example (python)
# python file amalgamation example (amalgamate cpython into one file)
import os
target_folder_name = r"repo\cpython"
output_file_name = "cpython.txt"
with open(output_file_name, "xb") as o_f:
for root, dirs, files in os.walk(target_folder_name):
for name in files:
_, ext = os.path.splitext(name)
if ext != ".c":
continue
current_filename = os.path.join(root, name)
with open(current_filename, "rb") as c_f:
o_f.write(c_f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment