def _save_private_file(filename, json_contents):
 temp_filename = tempfile.mktemp()
 file_desc = os.open(temp_filename, (os.O_WRONLY | os.O_CREAT), 384)
 with os.fdopen(file_desc, 'w') as file_handle:
  json.dump(json_contents, file_handle, sort_keys=True, indent=2, separators=(',', ': '))
 shutil.move(temp_filename, filename)

def _save_private_file ( filename , json_contents ) : temp_filename = tempfile . mktemp ( ) file_desc = os . open ( temp_filename , ( os . O_WRONLY | os . O_CREAT ) , 384 ) with os . fdopen ( file_desc , 'w' ) as file_handle : json . dump ( json_contents , file_handle , sort_keys = True , indent = 2 , separators = ( ',' , ': ' ) ) shutil . move ( temp_filename , filename )
saves a file with read-write permissions on for the owner .