FAQ
why this program shows ambiguous behavior ??

import os
import stat
import time
#import types

file_name=raw_input("Enter file name : ")
print file_name, "information"
st=os.stat(file_name)
print "mode", "=>", oct(stat.S_IMODE(st[stat.ST_MODE]))

print "type","=>",
if stat.S_ISDIR(st[stat.ST_MODE]):
print "DIReCTORY"
elif stat.S_ISREG(st[stat.ST_MODE]):
print "REGULAR"
elif stat.S_ISLINK(st[stat.ST_MODE]):
print "LINK"

print "file size", "=>",st[stat.ST_SIZE]
print "inode number", "=>",st[stat.ST_INO]
print "device inode resides on", "=>",st[stat.ST_DEV]
print "number of links to this inode", "=>",st[stat.ST_NLINK]
print "last accessed", "=>", time.ctime(st[stat.ST_ATIME])
print "last modified", "=>", time.ctime(st[stat.ST_MTIME])
print "inode changed", "=>", time.ctime(st[stat.ST_CTIME])



i ran this program in Winows XP SP2 in python 2.5.

Search Discussions

  • Steven D'Aprano at Jan 25, 2008 at 12:43 pm

    On Fri, 25 Jan 2008 04:28:43 -0800, asit wrote:

    why this program shows ambiguous behavior ??

    You should read this page, it will help you solve your problem:

    http://catb.org/~esr/faqs/smart-questions.html



    --
    Steven
  • Gabriel Genellina at Jan 25, 2008 at 5:50 pm

    On 25 ene, 10:28, asit wrote:

    why this program shows ambiguous behavior ??

    st=os.stat(file_name)
    print "file size", "=>",st[stat.ST_SIZE]
    print "inode number", "=>",st[stat.ST_INO]
    print "device inode resides on", "=>",st[stat.ST_DEV]
    print "number of links to this inode", "=>",st[stat.ST_NLINK]

    i ran this program in Winows XP SP2 in python 2.5.
    Using my recently repaired crystal ball, I see that you don't get what
    you expect for some of those fields. All files sharing the same inode,
    by example.
    The usual file systems used by Windows aren't built around the inode
    concept, they're different, so there is no "inode number" to report,
    among other things. From http://docs.python.org/lib/os-file-dir.html
    "On Windows, some items are filled with dummy values". Don't rely on
    anything but st_mode, st_size, and st_[cma]time, and perhaps a few
    more for fstat.

    --
    Gabriel Genellina

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJan 25, '08 at 12:28p
activeJan 25, '08 at 5:50p
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase