prototype = WINFUNCTYPE(c_int, HWND, LPCSTR, LPCSTR, UINT)
paramflags = (1, 'hwnd', 0), (1, 'text', 'Hi'), (1, 'caption', None), (1,
    'flags', 0)
MessageBox = prototype(('MessageBoxA', windll.user32), paramflags)
filename = 'readme.txt'
os.startfile(filename, 'edit')
try:
    os.startfile(filename, 'edit')
except WindowsError as e:
    MessageBox(text=str(e))
How do I open a file for edit from the command line under Windows?