r'\' - python parser bug?

Fuzzyman michael at foord.net
Mon Jun 7 16:12:49 CEST 2004


Duncan Booth <me at privacy.net> wrote in message news:<Xns95016EAEE7313duncanrcpcouk at 127.0.0.1>...
> michael at foord.net (Fuzzyman) wrote in 
> news:8089854e.0406070108.72739647 at posting.google.com:
> 
> > I've written a command line tool called filestruct that compares a
> > file structure to a previous state and records the changes (for
> > remotely syncing directories - you only have to transfer the changes
> > and then  filestruct will make the changes). If you give it a windows
> > path ending in \" then python interprets it *wrongly*....
> 
> Not that you ever need to give a well written script a path ending in \"? 
> Why not just give it the directory without the spurious path separator?
> 

It's not necessary - I just want to be able to handle it correctly if
it happens... after all, it's a perfectly valid path.

Hmm.. if other command line programs do the same then maybe I won'
trip up other users... but it seems weird..........

Regards,

Fuzzy

 
> > 
> > e.g.
> > D:\Python Projects\directory change >>> filestruct.py compare
> > "D:\Python Projects\" b:\test.txt b:\test.zip
> > filestruct needs at least three arguments when run from the command
> > line. See :
> > filestruct.py ?
> > 
> > The python interpreter assumes that the entirely valid windows path
> > supplied at the command line actually contains an escaped quote..... I
> > may have to write a new command line parser to correct this python
> > 'feature'.....
> > 
> Python here seems to be in complete agreement with Microft, or at least 
> with their C compiler (not entirely suprising since that's what Python 
> uses). The quote is indeed escaped:
> 
> C:\temp>type t.c
> #include <stdio.h>
> 
> int main(int argc, char **argv)
> {
>     int i;
>     for (i = 0; i < argc; i++)
>     {
>         printf("arg %d= %s\n", i, argv[i]);
>     }
> }
> 
> C:\temp>t "c:\Program Files\" c:\temp
> arg 0= t
> arg 1= c:\Program Files" c:\temp
> 
> C:\temp>



More information about the Python-list mailing list