-
-
Save Taisho/8ddab653b7f8c9661df59e4b920931cd to your computer and use it in GitHub Desktop.
Revisions
-
sligodave revised this gist
Sep 12, 2013 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,19 +2,18 @@ import tempfile file_descriptor, file_path = tempfile.mkstemp(suffix='.tmp') # You can convert the low level file_descriptor to a normal open file using fdopen with os.fdopen(file_descriptor, 'w') as open_file: open_file.write('hello') # OR without the 'with' open_file = os.fdopen(file_descriptor, 'w') open_file.write('hello') open_file.close() # OR without the open low level file_descriptor os.close(file_descriptor) open_file = open(file_path, 'w') open_file.write('hello') -
sligodave revised this gist
Sep 12, 2013 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,21 +3,19 @@ # Note: open_file here is a low level file descriptor, not an ordinary open file. file_descriptor, file_path = tempfile.mkstemp(suffix='.tmp') # You can convert the low level open_file to a normal open file using fdopen with os.fdopen(file_descriptor, 'w') as open_file: open_file.write('hello') # OR without the with open_file = os.fdopen(file_descriptor, 'w') open_file.write('hello') open_file.close() # OR without the low level file descriptor os.close(file_descriptor) open_file = open(file_path, 'w') open_file.write('hello') open_file.close() -
sligodave revised this gist
Sep 12, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ import os import tempfile -
sligodave renamed this gist
Sep 12, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ import os import tempfile -
sligodave created this gist
Sep 12, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import os import tempfile # Note: open_file here is a low level file descriptor, not an ordinary open file. open_file, file_path = tempfile.mkstemp(suffix='.tmp') # You can convert the low level open_file to a normal open file using fdopen with os.fdopen(open_file, 'w') as open_file: open_file.write('hello') # OR without the with open_file = os.fdopen(open_file, 'w') open_file.write('hello') open_file.close() # OR without the low level file descriptor os.close(open_file) open_file = open(file_path, 'w') open_file.write('hello') open_file.close() # You are responsibile for deleting your temp file os.unlink(file_path)