[Tutor] Trouble with os.path.isfile

Carroll, Barry Barry.Carroll at psc.com
Mon Jun 5 21:16:18 CEST 2006


Carlos:

Thank you for your response.  

It turns out that Python and os.path.isfile() are working as expected.
A permissions conflict on my Linux-based system caused the isfile
function to return false for all the entries in the directory.  The web
server is running as user apache.  The files were owned by user iip.  I
don't have all the details worked out yet, but it appears that adding
apache to iip's group list resolves the conflict.  

It would be nice if the library entries for os.path.is* (where * is one
of {file, dir, link, mount) mentioned this restriction.

Regards,
 
Barry
barry.carroll at psc.com
541-302-1107
________________________
We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed

> -----Original Message-----
> Date: Fri, 2 Jun 2006 23:28:21 -0700
> From: "Carlos Daniel Ruvalcaba Valenzuela" <clsdaniel at gmail.com>
> Subject: Re: [Tutor] Trouble with os.path.isfile
> To: tutor at python.org
> Message-ID:
> 	<4fae7dfa0606022328k57c6a5cewee68fa1a33537e6b at mail.gmail.com>
> Content-Type: text/plain; charset=WINDOWS-1252; format=flowed
> 
> From: Carlos Daniel Ruvalcaba Valenzuela <clsdaniel at gmail.com>
> Date: Jun 2, 2006 11:10 PM
> Subject: Re: [Tutor] Trouble with os.path.isfile
> To: "Carroll, Barry" <Barry.Carroll at psc.com>
> 
> 
> Here is the problem IMO:
> 
> I did some modifications to your code (very minimal on ifs) and it
worked:
> 
> import os
> 
> def lstdirsnfiles(tdir):
>     flst = os.listdir(tdir)
>     flst.sort()
> 
>     fnames = []
>     dnames = ['.', '..']
> 
>     for name in flst:
>         absfn = os.path.join(tdir, name)
> 
>         if os.path.isdir(absfn):
>             dnames.append(name)
> 
>         if os.path.isfile(absfn):
>              fnames.append(name)
>     return (dnames, fnames)
> 
> (dirs, files) = lstdirsnfiles('/home/clsdaniel')
> 
> It returns correctly all directories and files.
> 
> Regards
> Carlos Daniel Ruvalcaba Valenzuela
<<snip>>




More information about the Tutor mailing list