Skip to content

Instantly share code, notes, and snippets.

View esmitt's full-sized avatar
🐢
As fast as a Pentium I

esmitt esmitt

🐢
As fast as a Pentium I
View GitHub Profile
@esmitt
esmitt / one_single_file.py
Last active April 15, 2025 14:21
Return a single string with the content of all files inside a folder. For each file, it indicates the filename and its content. for now, ignore single-line comments. Very useful to ask to ChatGPT for instance about what is wrong with your code
from pathlib import Path, PurePath
from typing import List, Optional
def stringify_file(filename: str) -> str:
single_file = ""
with open(filename, encoding="utf-8") as file:
for line in file:
stripped = line.strip()
if stripped:
code_part = line.split('#')[0]