[EMAIL PROTECTED] wrote:
> The following code fails (pythonbugtest.exe takes one parameter, a
> string):
>
> import os
> result = os.system('"pythonbugtest.exe" "test"')
> assert(result == 0)
>
> The error message is:
>
> 'pythonbugtest.exe" "test' is not recognized as an internal or external
> command, operable program or batch file.
> Traceback (most recent call last):
> File "C:\Nick\!My Programs\Python\bugtest\python1.py", line 8, in ?
> assert(result == 0)
> AssertionError
>
> If I remove the quote marks around "pythonbugtest.exe" or "test", it
> works fine. But sometimes I need those quote marks, if e.g. there are
> spaces in filenames.
>
> I think this is a bug?
yup, but unfortunately, it's a bug at the windows level, not in Python. from
what
I can tell, the problem is that cmd.exe cannot parse the command string it's
given
by the C-level system() call.
possible workarounds:
1. get rid of the quotes around the command name:
result = os.system('pythonbugtest.exe "test"')
2. add an extra quote (!) before the quoted command name:
result = os.system('""pythonbugtest.exe" "test"')
3. use os.spawn or the subprocess module instead.
</F>
--
http://mail.python.org/mailman/listinfo/python-list