python os.path.exists failure

koranthala koranthala at
Sat Oct 31 16:26:46 CET 2009

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'
    print 'No file found in path - %s' %path
print Popen(path, stdout=PIPE, shell=True)

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

What is the usual solution to this?

More information about the Python-list mailing list