r'\' - python parser bug?

Thomas Heller theller at python.net
Mon Jun 7 11:30:07 CEST 2004


michael at foord.net (Fuzzyman) writes:

> *However* - more seriously - if you create a command line tool, then
> python *wrongly* handles pathnames.
>
> 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*....
>
> 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'.....

That's not a python bug - a C program shows the same behaviour.  You're
most probably bitten by how cmd.exe handles quoted arguments.

Thomas





More information about the Python-list mailing list