def sudo(executable, args=None):
 if (not args):
  args = []
 execute_info = ShellExecuteInfo(fMask=(SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE), hwnd=GetActiveWindow(), lpVerb='runas', lpFile=executable.encode('utf-8'), lpParameters=subprocess.list2cmdline(args).encode('utf-8'), lpDirectory=None, nShow=SW_SHOW)
 if (not all((stream.isatty() for stream in (sys.stdin, sys.stdout, sys.stderr)))):
  raise NotImplementedError('Redirection is not supported')
 if (not ShellExecuteEx(byref(execute_info))):
  raise ctypes.WinError()
 wait_and_close_handle(execute_info.hProcess)

def sudo ( executable , args = None ) : if ( not args ) : args = [ ] execute_info = ShellExecuteInfo ( fMask = ( SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE ) , hwnd = GetActiveWindow ( ) , lpVerb = 'runas' , lpFile = executable . encode ( 'utf-8' ) , lpParameters = subprocess . list2cmdline ( args ) . encode ( 'utf-8' ) , lpDirectory = None , nShow = SW_SHOW ) if ( not all ( ( stream . isatty ( ) for stream in ( sys . stdin , sys . stdout , sys . stderr ) ) ) ) : raise NotImplementedError ( 'Redirection is not supported' ) if ( not ShellExecuteEx ( byref ( execute_info ) ) ) : raise ctypes . WinError ( ) wait_and_close_handle ( execute_info . hProcess )
a nicer version of sudo that uses getpass to ask for a password .