confusing behaviour of os.system

Ben Cartwright bencvt at gmail.com
Thu Apr 6 22:23:27 EDT 2006


Todd wrote:
> I'm trying to run the following in python.
>
> os.system('/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file
> \"test.c\")"')

Python is interpreting the \"s as "s before it's being passed to
os.system.  Try doubling the backslashes.

>>> print '/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"'
/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> "test.c")"
>>> print '/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \\"test.c\\")"'
/usr/bin/gnuclient -batch -l htmlize -eval "(htmlize-file> \"test.c\")"

--Ben




More information about the Python-list mailing list