how to know if folder contents have changed
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Mon Nov 12 00:27:09 EST 2007
On Sun, 11 Nov 2007 21:03:33 -0800, devnew at gmail.com wrote:
> one scheme suggested was to create a string from the names of sorted
> image files and give it as the cache name..
> ie ,if i have one.jpg,three.jpg,new.jpg ,
> i will name the cache as 'newonethree.cache' and everytime i want to
> check if new image added/removed i wd create a string from the
> contents of folder and compare it with cachename.
>
> this scheme is ok for a small number of files,..
Not really.
`xxx.jpg` -> `xxx.cache`
Now `xxx.jpg` is deleted and `x.jpg` and `xx.jpg` are created.
`x.jpg`, `xx.jpg` -> `xxx.cache`
> can someone suggest a better way? i know it is a general programming
> problem..but i wish to know if a python solution exists
Don't store the names in the cache file name but in the cache file. Take
a look at the `set()` type for operations to easily find out the
differences between two set of names and the `pickle` module to store
Python objects in files.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list