Author Mohanson Leaf
Recipients Mohanson Leaf, paul.moore, steve.dower, tim.golden, zach.ware
Date 2016-09-09.09:24:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473413094.07.0.556978499762.issue28041@psf.upfronthosting.co.za>
In-reply-to
Content
os.stat(file).st_nlink gives 1 but same file's st_nlink from os.scandir(dir) gives 0.


"""
Inconsistent behavior: Get st_nlink from os.stat() and os.scandir()
Platform: Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
"""

import os
import os.path

print('os.stat:', os.stat(__file__).st_nlink)

for entry in os.scandir(os.path.dirname(os.path.abspath(__file__))):
    if entry.name == 'stat.py':
        print('os.scandir:', entry.stat().st_nlink)

"""
os.stat: 1
os.scandir: 0
"""
History
Date User Action Args
2016-09-09 09:24:54Mohanson Leafsetrecipients: + Mohanson Leaf, paul.moore, tim.golden, zach.ware, steve.dower
2016-09-09 09:24:54Mohanson Leafsetmessageid: <1473413094.07.0.556978499762.issue28041@psf.upfronthosting.co.za>
2016-09-09 09:24:54Mohanson Leaflinkissue28041 messages
2016-09-09 09:24:53Mohanson Leafcreate