From: Michael H. <mh...@al...> - 2005-11-07 13:24:28
|
Juho Schultz wrote: > Or you could use raw strings: > > r"c:\docume~1\noelo'~1\locals~1\temp\tmpcxnwsm" > > So python treats \ in the string just like any other character. The problem isn't Python's string translation, it is gnuplot's. The situation is that there is a valid python string containing a filename, and that filename has to be passed to gnuplot quoted in such a way that gnuplot interprets it as the original string. For all characters except "'" (single-quote), simply single-quoting the string to gnuplot works. But there doesn't seem to be any way to pass a single quote to gnuplot within a single-quoted string (e.g., '\'' results in a two-character string containing "\" and "'"). So if we need to support filenames with single-quotes, we have to use gnuplot's double-quoted format. I think double-quoted strings should work OK, but we have to quote both '"' (double-quote) and "\" (backslash). It might not be necessary to handle double-quote for windows filenames, but we should handle it anyway for generality. Then, I believe, we could use the same quoting code for all operating systems. Michael |