r'\' - python parser bug?
me at privacy.net
Mon Jun 7 11:52:58 CEST 2004
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?
> 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
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:
int main(int argc, char **argv)
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
More information about the Python-list