Steve Willoughby wrote: > On 11-May-11 15:54, Prasad, Ramit wrote: >>> Core windows commands don't generally accept it, including native >>> Windows applications (although sometimes they're lenient in what they >>> accept). It'll work for command-line Python script usage because it's >>> *python* that allows them, not *windows*. >> >> They work in *Windows* command prompt natively. > > Respectfully, I think you aren't clear on how command line execution > works. Hopefully I can help a little (yes, there are enough cases where > it'll bite you that it's good to know this). > >> Some apps do not work well that is true, but the reason that theywork >> like this with Python is NOT because Python allows it but because > Windows does. I highly doubt Python checks for "/" and converts it to > "\\" (or does any complicated checking of file strings). YMMV for apps, > but I have never had a problem with '/' on the command prompt. It is an > important caveat to note that this behavior is not Guaranteed. > > Actually, yes, that's exactly what Python (or actually the underlying > file handling libraries it's built with) is doing on Windows. There is > a decades-long tradition of C compilers (et al) doing this conversion > for the sake of all the ported Unix C programs that people wanted to run > on Windows (or, at the time, MSDOS). > > If Windows natively supported it, then you could do this: > > C:\> DIR /users/fred/desktop > C:\> DEL /temp/myfile > > Or try running your Python program like > > C:\> /python27/python.exe scriptname.py > > That doesn't work either, because Windows is NOT in any way at all > interpreting the / characters. > > So why does this work: > > C:\> myscript.py /temp/myfile /users/fred/desktop > > or even > > C:\> \python27\python.exe myscript.py /temp/myfile > > That works because Windows hands ALL of the argument strings, as-is, > with NO interpretation, to the application to deal with. In this case, > the application is Python, and Python is going to the extra work to > interpret the / characters as \ characters when you try to use them in > open() calls and the like. >
The following suggests otherwise: """ Note File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections. """ (Found at http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx ) _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor