28 Aug 23:52
Checking if the file is a symlink fails
From: saswat <at> gmail.com <saswat <at> gmail.com>
Subject: Checking if the file is a symlink fails
Newsgroups: gmane.comp.python.general
Date: 2008-08-28 21:55:54 GMT
Subject: Checking if the file is a symlink fails
Newsgroups: gmane.comp.python.general
Date: 2008-08-28 21:55:54 GMT
check if file is a symlink Here is a small piece of code: import os from stat import * filePath = "/home/xyz/symLinkTest" mode = os.stat(filePath)[ST_MODE] print 'Find using os.path : ',os.path.islink(filePath) print 'Find using mode :', S_ISLNK(mode) print 'Is this a regular file : ' S_ISREG(mode) Output : --------- Find using os.path : True Find using mode : False Is this a regular file : True File symLinkTest is a symbolic link. Why S_ISLNK(mode) returns False and S_ISREG(mode) returns True ? -- http://mail.python.org/mailman/listinfo/python-list
RSS Feed