On 2014-06-16 20:41, Chris Angelico wrote:
> Oops! I made the cardinal error of trying in one and assuming it'd
> work in both. Just needs a b prefix on the split string:
> def shell_split(cmd):
>     return subprocess.check_output("""python -c 'import sys;
> print("\\0".join(sys.argv[1:]))'
> """+cmd,shell=True)[:-1].split(b"\0")
> You'll get back a list of byte strings, in any case. Feel free to
> pass them through a decode operation, or to incorporate a .decode()
> into the above stream, as you wish.

Tested on Win32?  The behavior of "shell expansion" on Windows
cmd.exe differs from most *nix shells (i.e., it *doesn't* expand, so
you have to do it yourself), so Antoon would need to describe the
desired behavior on Win32.



Reply via email to