how do i check if a file exists with python?

David C. Ullrich ullrich at math.okstate.edu
Sun Dec 31 11:28:30 EST 2000


On Sun, 31 Dec 2000 13:10:30 GMT, ullrich at math.okstate.edu (David C.
Ullrich) wrote:

>On Sun, 31 Dec 2000 17:39:21 +0200 (IST), Moshe Zadka
><moshez at zadka.site.co.il> wrote:
>
>>On Fri, 29 Dec 2000 14:02:25 GMT, ullrich at math.okstate.edu (David C. Ullrich) wrote:
>[...]
>>
>>> I sometimes make cumulative backups of files containing
>>> important stuff. I sort of need to determine that file.001,
>>> file.002 and file.003 already exist and file.004 does not
>>> before deciding what to name the current backup file.
>>
>>That's *really* evil. What if there is another version of your
>>process running???  Damn!, just lost that backup file. In that
>>case, I'd go for a Maildir-like algorithm, which promises no colisions.
>>Actually, in that case, usually what you want is CVS, but that's
>>a matter for another day.
>
>[...] Is it possible
>to give a hint how a "Mailder-like" algorithm
>promises no collisions?

Oh. I thought that Maildir was like the name of the guy who invented
the algorithm. It's Maildir, like a dir where incoming mail goes.
Google.Bernstein says in part

"Why should I use maildir?

Two words: no locks. An MUA can read and delete messages while new
mail is being delivered: each message is stored in
a separate file with a unique name"

I'd considered the idea that each piece of input could become a
separate file but I thought there was probably a cleverer way to
do it. But if it's good enough for maildir it's probably good enough.

>DU




More information about the Python-list mailing list