why not using tmp file? http://docs.python.org/2/library/tempfile.html