mailbox.mbox.add() sets access time as well as modification time
tinnews at isbd.co.uk
tinnews at isbd.co.uk
Sun Apr 26 11:16:49 EDT 2009
Grant Edwards <invalid at invalid> wrote:
> > I suppose I could do the following:-
> >
> > lock the mbox
> > get the atime
> > add the new message with mailbox.mbox.add()
> > restore the atime
> > unlock the mbox
>
> You could fix mbox.add(). ;)
>
Yes, but I'm not sure that I'm that competant!
> > All I need to do now is find out how to get and set atime with python.
>
> You use os.utime().
>
> From http://docs.python.org/library/os.html#module-os:
>
> os.utime(path, times)
>
> Set the access and modified times of the file specified by
> path. If times is None, then the file's access and
> modified times are set to the current time. (The effect is
> similar to running the Unix program touch on the path.)
> Otherwise, times must be a 2-tuple of numbers, of the form
> (atime, mtime) which is used to set the access and modified
> times, respectively. Whether a directory can be given for
> path depends on whether the operating system implements
> directories as files (for example, Windows does not). Note
> that the exact times you set here may not be returned by a
> subsequent stat() call, depending on the resolution with
> which your operating system records access and modification
> times; see stat().
>
> Changed in version 2.0: Added support for None for times.
>
> Availability: Unix, Windows.
>
Thanks!
--
Chris Green
More information about the Python-list
mailing list