CSV module, DictReader problem (bug?)

Fredrik Lundh fredrik at pythonware.com
Thu Nov 2 07:34:06 CET 2006


John Machin wrote:

> Not all APIs do the right thing. If you fire up the cmd.exe shell and
> feed it slashes as path separators, it barfs. Example:
>     C:\junk>dir c:/junk/*.bar
>     Invalid switch - "junk".
> Hence the advice to use rawstrings with backslashes -- they work under
> all circumstances.

we went through this a couple of days ago; all Windows API:s are 
*documented* to accept backward or forward slashes, the command shell is 
*documented* to only accept backward slashes.

if you're wrapping some cmd.exe command in an internal API, it's usually 
easier to call "os.path.normpath" the last thing you do before you call 
"os.system", than to get all the backslashes right in your code.

also see:

http://www.effbot.org/pyfaq/why-can-t-raw-strings-r-strings-end-with-a-backslash.htm

</F>




More information about the Python-list mailing list