# -*- coding: utf-8 -*-
import os
import subprocess
import tempfile
fhandle, fname = tempfile.mkstemp(suffix='.txt', dir='.')
try:
with os.fdopen(fhandle, mode='w') as file:
file.write('Hello world!')
file.flush()
os.fsync(file.fileno())
subprocess.call(['notepad', fname])
finally:
os.remove(fname)