Skip to content

Instantly share code, notes, and snippets.

@adamv
Created June 5, 2015 17:57
Show Gist options
  • Save adamv/3f67a16a605e11627bed to your computer and use it in GitHub Desktop.
Save adamv/3f67a16a605e11627bed to your computer and use it in GitHub Desktop.
Create and use a temporary file.
#!/usr/bin/env python3.4
import tempfile
from subprocess import call
with tempfile.NamedTemporaryFile() as f:
for i in range(500):
f.write(bytes("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\n", 'UTF-8'))
f.flush()
call(["cat", f.name])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment