CSV module, DictReader problem (bug?)

John Machin sjmachin at lexicon.net
Thu Nov 2 00:11:19 EST 2006


On 2/11/2006 2:38 PM, skip at pobox.com wrote:
>     >> ...alternatively you can just use 'unix slashes', e.g.
>     >> 'c:/temp/book1.csv', since those work just fine 'cause the Windows
>     >> APIs deal with them properly.
> 
>     John> Not all APIs do the right thing. If you fire up the cmd.exe shell
>     John> and feed it slashes as path separators, it barfs. Example:
>     John>     C:\junk>dir c:/junk/*.bar
>     John>     Invalid switch - "junk".
>     John> Hence the advice to use rawstrings with backslashes -- they work
>     John> under all circumstances.
> 
> I think he means "the Windows APIs" within a Python program.
> 
> Skip
> 

I too think he meant that. I left the mental gymnastics of wrapping what 
I wrote into an os.system call as an exercise for the reader.

| >>> import os
| >>> os.system("dir c:/junk/*.bar")
| Invalid switch - "junk".
| 1
| >>> os.system(r"dir c:\junk\*.bar")
| [snip]
| 02/11/2006  01:21 PM                 8 foo.bar
| [snip]
| 0
| >>>

Cheers,
John






More information about the Python-list mailing list