saswat@gmail.com | 29 Aug 01:41

Re: Checking if the file is a symlink fails

On Aug 28, 3:11 pm, Christian Heimes <li...@cheimes.de> wrote:
> sas...@gmail.com wrote:
> > File symLinkTest is a symbolic link.
>
> > Why S_ISLNK(mode) returns False and S_ISREG(mode) returns True ?
>
> Because you are using os.stat() instead of os.lstat().
>
> http://docs.python.org/lib/os-file-dir.html
>
> Christian

Do you mean the following is deprecated ?
http://docs.python.org/lib/module-stat.html

>From the documentation -

S_ISLNK( mode)
    Return non-zero if the mode is from a symbolic link.

Thanks
-Saswat
--
http://mail.python.org/mailman/listinfo/python-list

Miles | 29 Aug 07:06

Re: Checking if the file is a symlink fails

saswat wrote:
> On Aug 28, 3:11 pm, Christian Heimes wrote:
>> sas...@gmail.com wrote:
>> > File symLinkTest is a symbolic link.
>>
>> > Why S_ISLNK(mode) returns False and S_ISREG(mode) returns True ?
>>
>> Because you are using os.stat() instead of os.lstat().
>
> Do you mean the following is deprecated ?
> http://docs.python.org/lib/module-stat.html
>
> >From the documentation -
>
> S_ISLNK( mode)
>    Return non-zero if the mode is from a symbolic link.

No, it means that os.stat follows the symbolic link and gives stat
information for the file that the symbolic link points to, which is
*not* a symbolic link.  Like the documentation for lstat says: "Like
stat(), but do not follow symbolic links."  But why not just use
os.path.islink?

-Miles
--
http://mail.python.org/mailman/listinfo/python-list

Fredrik Lundh | 29 Aug 07:20

Re: Checking if the file is a symlink fails

saswat <at> gmail.com wrote:

> Do you mean the following is deprecated ?
> http://docs.python.org/lib/module-stat.html
> 
>>From the documentation -
> 
> S_ISLNK( mode)
>     Return non-zero if the mode is from a symbolic link.

As that page states, that's a function used to interpret a mode flag 
returned by os.stat, os.fstat, or os.lstat.  It obviously won't give you 
the result you're looking for if you use a stat function that *follows* 
symbolic links.

</F>

--
http://mail.python.org/mailman/listinfo/python-list


Gmane