Skip to content

Instantly share code, notes, and snippets.

@avalanchy
Created February 6, 2014 12:27
Show Gist options
  • Save avalanchy/8843219 to your computer and use it in GitHub Desktop.
Save avalanchy/8843219 to your computer and use it in GitHub Desktop.
python. prepend file with text
def prepend(path, text)
with open(path, 'r+') as f:
body = f.read()
f.seek(0)
f.write(text + body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment