Waldemar Osuch <waldemar.os...@gmail.com> wrote: > On Fri, May 21, 2010 at 15:03, Bill Janssen <jans...@parc.com> wrote: > > Anyone know if the quote() function in the "pipes" module does the right > > thing for cmd.exe pipes? > > > > If not, what is the right thing? > > > twisted.python.win32 has a couple functions that try very hard to get > the quoting right. > http://twistedmatrix.com/documents/current/api/twisted.python.win32.html#quoteArguments
There also seems to be an undocumented function (not a method, as the docs erroneously mention in passing) in the "subprocess" module, called "list2cmdline", which appropriately quotes things for win32's CreateProcess(). Interesting to see that both functions do the same thing: MARLOWE-VM:~ $ python -i Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import subprocess >>> subprocess.list2cmdline(["That's the game! says Mike \"Hammer\" Brotsky"]) '"That\'s the game! says Mike \\"Hammer\\" Brotsky"' >>> import pipes >>> pipes.quote("That's the game! says Mike \"Hammer\" Brotsky") '"That\'s the game! says Mike \\"Hammer\\" Brotsky"' >>> And the code in Twisted generates the same thing: >>> import win32 >>> win32.quoteArguments(["That's the game! says Mike \"Hammer\" Brotsky"]) '"That\'s the game! says Mike \\"Hammer\\" Brotsky"' >>> Bill _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32