File Path retrieving problem

Steve Holden steve at holdenweb.com
Wed Feb 25 23:03:09 EST 2009


music24by7 at gmail.com wrote:
> 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.
> 
Look, we aren't psychic. We can't debug code and directories we can't
see. Work with us here - give us the information we need to help you.

The actual code. A directory listing? Any error messages?

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list