It leaves out the call to localtime, but now you're constructing a
datetime object, so it's really not more direct. Some may find it
more readable, or at least I think it is, er... well slightly

On Linux os.stat() returns an object of type posix.stat_result,
I wonder if this type could be enhanced so that one could do this:

os.stat('thefile').mdatetime.strftime('%y%d%m')

(mdatetime returning a datetime object)

Naturally we'd probably want os.stat('thefile').cdatetime and so
on too...

--- 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?
>
> Bill
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!