WmGill wrote:
I want to write a script that Among other things) renames a file based on
it's timestamp.
I can get the date info using
"strftime('%y%m%d',localtime(os.stat('thefile' )[ST_MTIME])", but this seems
like a long way around the block. Is there a more direct way?
More direct way for what? os.stat() directly returns the time in seconds,
localtime() converts it to a nice tuple with year, month, day, etc., and
strftime() is a handy way to turn that into a string based on various
components.
If you don't want a string, you could of course stop before calling stftime(),
so that would be more direct. If you are certain you only want the year
month and day, you could skip the strftime() call and just do a % formatting
with '%04d%02d%02d' % localtime()[:3], but that's slightly less readable.
-Peter