[CentralOH] os.stat
Mark Erbaugh
mark at microenh.com
Mon May 12 04:49:33 CEST 2008
I'm working on a program that needs to extract a date* from a file and
I'm using the os.stat function. I'm running Ubuntu Linux.
import os
import stat
import datetime
datetime.datetime.fromtimestamp(os.stat[stat.ST_CTIME])
On several files that I've tested, this code returns the same date that
I get from ls -l. However, for one file, the time is off by about 8
seconds. It this a rounding issue or is it actually retrieving a
different date? Or is it something else altogether?
Thanks,
Mark
* ideally the creation date, but from the Python docs, it looks like
under Unix (and I assume Linux) it is actually the date of the last
metadata change (whatever that is).
More information about the CentralOH
mailing list