On 4/8/2012 7:11 AM, Xah Lee wrote:

so recently i switched to a Windows version of python. Now, Windows
version takes path using win backslash, instead of cygwin slash.

Python passes strings to Windows functions as the user requests. In spite of the fact that command.com and cmd.exe (command prompt window) require backslashes for paths that they proccess, the internal Windows functions all (as far as I know) accept slashes in paths. Slashes are used for options only at the shell level. So within a Python program, one can use slashes on Windows too, just as you are used to.

open("C:/users/terry/data/somefile.txt")

I just verified that you can pass arguments with slashes, such as a path, to a Python program from the shell. Here is my tem.py:

import sys
print(sys.argv)

If I run it from its directory as current path:

F:\Python\mypy>c:\programs\python32\python.exe tem.py /a/b
['tem.py', '/a/b']

If the current directory were not the directory containing the script, then one would have to use backslashes for the path to the script and would see backslashes in sys.argv[0]. If I execute tem.py in IDLE, the output is

['F:\\Python\\mypy\\tem.py']

because IDLE 'starts in' the python.exe directory and Windows functions produce paths with '\' even though they accept them with '/'.

Try aiming your ire at the right target. The title of this post should have been Fuck Microsoft for the billion (at least) in time, effort, and annoyance they inflicted on the world by being intentionally different from and conflicting with unix on shell syntax.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to