Checking if the file is a symlink fails

Miles semanticist at
Fri Aug 29 07:06:12 CEST 2008

saswat wrote:
> On Aug 28, 3:11 pm, Christian Heimes wrote:
>> sas... at 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 ?
> >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


More information about the Python-list mailing list