This problem happens in launching Python from Windows. A quoted pathname is used as parameter. If and only if the pathname is ended with a trailing \, it is treated as an escape character. p.py ------------------------------------------------------- import sys from pprint import pprint pprint(sys.argv) ------------------------------------------------------- Note slash inside the quote is treated as path separators g:\usr\bin>c:\python24\python.exe g:\usr\bin\p.py " tung\wai\yip" wai ['g:\\usr\\bin\\p.py', 'tung\\wai\\yip', 'wai'] However the trailing \ is treated as an escape character for the quote. Only command line parameter is presented in sys.argv. g:\usr\bin>c:\python24\python.exe g:\usr\bin\p.py " tung\wai\yip\" wai ['g:\\usr\\bin\\p.py', 'tung\\wai\\yip" wai']
Logged In: YES user_id=1126061 After having a quick look it appears as though python is in fact stripping the trailing '\'. the argv array that the python interpreter is passed contains the backslash so it must be doing away with it.
Logged In: YES user_id=561546 I don't completely follow your logic. But I have reproduce this with Java so it looks very likely that it is a Windows bug. In addition, a workaround is to add as extra \ at the end of the first argument if you know it is going to end in \. This is illustrated in the last example. P.java ------------------------------------------------------------ public class P { public static void main(String argv[]) throws Exception { for (int i=0; i < argv.length; i++) { System.out.println("argv " + i + " " + argv[i]); } } } ----------------------------------------------------------- BAD c:\>java P "tung\wai\yip\" wai argv 0 tung\wai\yip" wai GOOD c:\>java P "tung\wai\yip\\" wai argv 0 tung\wai\yip\ argv 1 wai -----------------------------------------------------------