os.path.setmtime ?

Holger Krekel pyth at devel.trillke.net
Mon Oct 13 14:33:46 EDT 2003


Richard Wesley wrote:
> I am trying to set the mod date on a file (Linux) as part of a unit test 
> run.  I can just wait one second, but that slows the test down.  A 
> better solution would be to tweak the mod date on a file, but os.path 
> does not seem to have setmtime.  
> 
> Is there any simple way to do this?

it is spelled

    os.utime

in python.  

    os.utime(path, None)

will set a/mtime to current time and

    os.utime (path, (-1, newtime))

will set mtime to newtime.  Note, however, that the effects and the
actual time resolution of this call are very platform independant. 

cheers,

    holger





More information about the Python-list mailing list