Re: [Tutor] Preserving timestamps when DLing with ftplib / gzip?

Magnus Lycka magnus at
Mon Nov 24 16:35:12 EST 2003

Terry Carroll wrote:
> Is there a way to do this?  I suppose I'd first have to somehow use ftplib 
> to find out the timestamp on the remote file, and then use some sort of 
> interface to set it on the files I create, right?

That sounds reasonable. (Maybe there is a shortcut I don't know.)

I don't know of a better way to get times than to do a directory
listing and parsing the output. Did I miss something?

To set times on the local side, use the os module:

>>> import os
>>> help(os.utime)
Help on built-in function utime:

    utime(path, (atime, utime))
    utime(path, None)
    Set the access and modified time of the file to the given values.  If the
    second form is used, set the access and modified times to the current time.

Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65  mailto:magnus at

More information about the Tutor mailing list