On Sat, Oct 31, 2009 at 11:26 AM, koranthala <koranth...@gmail.com> wrote: > Hi all, > My code is as follows: > > path = r'C:/"Program Files"/testfolder/2.3/test.txt' > if os.path.lexists(path): > print 'Path Exists' > else: > print 'No file found in path - %s' %path > print Popen(path, stdout=PIPE, shell=True).stdout.read() > > The output comes as > No file found in path - C:/"Program Files"/testfolder/2.3/test.txt > but the test.txt file is opened. > > The issue, I guess, is that the double quotes inside is failing the > check. But without the double quotes, Popen fails. > One solution, I can think is to check without double quotes, and then > using some code, put the double quotes back inside, but it looks quite > kludgy. >
Just out of curiosity, does 'C:/"Program FIles"/' even work on the Windows command line? The usual procedure is to put the entire path in quotes. r'"C:\Program Files\..."'. > What is the usual solution to this? > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list