On Thu, 12 May 2005 14:20:29 -0000, Grant Edwards <[EMAIL PROTECTED]> wrote:
>On 2005-05-12, Brian van den Broek <[EMAIL PROTECTED]> wrote:
>
>>> b1="c:\test.txt"
>>> os.system('notepad.exe ' + b1)
>>>
>>> However, the t of test is escaped by the \, resulting in Notepad trying
>>> to open "c: est.txt".
>
>> There are several ways, but the preferred solution is to switch the
>> slash direction: "c:/test.txt". Python's smart enough to notice its
>> running on Windows and do the right thing with the slash.
>
>Does Python really look at the string and mess with the slash?
>I don't think it needs to, since the Windows system calls have
>always accepted forward slashses, haven't they?
>
For a path parameter, I think so. But various command shells us '/' the
way unix uses '-' -- i.e., for options/switches. E.g.
ls -R foo/bar
would work as
dir /s "foo/bar"
since the shell would pass on the quoted string to the os level (with quotes
removed)
Likewise
dir foo\bar/s
would work, but not
dir foo/bar/s
or
dir/s foo/bar
I don't know why MS used backslashes when unix had a perfectly good path syntax
(not to mention drive letter idiocy). Maybe some legal idiocy, wanting to be
different to be safe from SCO types?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list