File Path retrieving problem

music24by7 at gmail.com music24by7 at gmail.com
Wed Feb 25 22:37:38 EST 2009


On Feb 26, 2:35 am, Emile van Sebille <em... at fenx.com> wrote:
> Peter Otten wrote:
> > Maybe it's about access rights?
>
> > $ mkdir alpha
> > $ touch alpha/beta
> > $ python -c"import os; print os.path.exists('alpha/beta')"
> > True
> > $ chmod u-x alpha
> > $ python -c"import os; print os.path.exists('alpha/beta')"
> > False
> > $
>
> > I Don't know how this is handled on Windows...
>
> Here's one way....
>
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
> C:\>mkdir alpha
> C:\>touch alpha\beta  # cygwin at work here...
>
> C:\>python -c"import os; print os.path.exists('alpha/beta')"
> True
>
> C:\>cacls alpha /E /R "Everyone"
> processed dir: C:\alpha
> C:\>cacls alpha /E /R "Users"
> processed dir: C:\alpha
> C:\>cacls alpha /E /R "Administrators"
> processed dir: C:\alpha
>
> C:\>python -c"import os; print os.path.exists('alpha/beta')"
> False

Hi,

This is the following code which i have used to retrieve the pathname
of a filename given by the user

        filename = self.enText.get() # get the text entered in the
text box
        if os.path.exists(filename): # checking if the filename
exists , had replaced it with os.path.exists(os.path.abspath
(filename))
            print os.path.abspath(filename)
        else:
            print "Not found"

actually i need to list all the files/folders with the given filename
alongwith path and store it in an CSV file with index.

But i am unable to get even a single filepath correctly.
Whatever filename i enter the output is as : C:\Python25\WorkSpace
\xyz
i.e the name i entered is being appended to my workspace and
displayed.
Guys, i am not able to understand what shall i do here...plz help me
out.


Regards,
Sudhir



More information about the Python-list mailing list