python question
Paul Lussier
p.lussier at comcast.net
Fri Apr 15 22:07:00 EDT 2005
Hi all,
If I use os.path.getmtime("foo"), how do I convert that into into
something useful? I've tried using
date.fromtimestamp(os.path.getmtime("foo")), but that seems to not
work for some reason:
>>> import os
>>> import date
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named date
>>> import time
>>> date.fromtimestamp(os.path.getmtime("/Users/pll/.emacs"))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'date' is not defined
>>> os.date.fromtimestamp(os.path.getmtime("/Users/pll/.emacs"))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'date'
>>> time.date.fromtimestamp(os.path.getmtime("/Users/pll/.emacs"))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'date'
I'm trying get the mtime of a file in order to compare that to a
timestamp stored in a file in ctime(3) format (e.g., "Thu Oct 13
04:54:34 1994"). So I either need to convert the timestamp in the
file from ctime to the format I get from python's os.path.getmtime(),
or convert that to the ctime string format. Any ideas?
Thanks,
--
Seeya,
Paul
More information about the gnhlug-discuss
mailing list