Skip to content

Instantly share code, notes, and snippets.

@islem-esi
Created April 23, 2022 11:10
Show Gist options
  • Save islem-esi/f572be00517b179f436ce82350d31685 to your computer and use it in GitHub Desktop.
Save islem-esi/f572be00517b179f436ce82350d31685 to your computer and use it in GitHub Desktop.
def load_all_files(rootdir):
files_code = []
for subdir, dirs, files in os.walk(rootdir):
for file in files:
if file.endswith('.py'):
with open(os.path.join(subdir, file)) as pf:
try:
code = pf.read()
files_code.append(code)
except:
print('encoding error')
return files_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment