python os.path.exists failure
benjamin.kaplan at case.edu
Sat Oct 31 16:35:16 CET 2009
On Sat, Oct 31, 2009 at 11:26 AM, koranthala <koranthala at 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'
> 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
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?
More information about the Python-list