Reputation: 295904
At the Windows command line, the following behaves exactly as expected:
C:\> c:\cygwin\bin\printf "<%s>\n" "{foo}"
{foo}
From inside a native win32 Python instance, however, the curly brackets are stripped:
>>> subprocess.Popen(['c:\\cygwin\\bin\\printf', '<%s>\n', '{foo}'],
... stdout=subprocess.PIPE).communicate()[0].rstrip('\n')
'foo'
What's going on here?
Upvotes: 2
Views: 1418
Reputation: 2763
You should be able to use pipes.quote()
to resolve this issue:
http://docs.python.org/2/library/pipes.html#pipes.quote
Alternatively, if you're on python3, checkout shlex.quotes(): http://docs.python.org/2/library/shlex.html#module-shlex
Upvotes: 2