[Python-Dev] Acquire/release functionality

Chermside, Michael mchermside@ingdirect.com
Thu, 6 Feb 2003 17:26:30 -0500


Alex Martelli writes:
> I *LIKE* this: a termination-method SHOULD be idempotent
> (a no-op when called more than once), so that if various ways to
> "ensure the termination method is called" happen to be used all
> at once, that doesn't break anything.

I'm not sure I agree. You write your code which does 3 different
things to ensure that the file gets closed. Then I, the poor
maintenance programmer, is asked to make a change... don't close
the file until later on. I find the spot in the code where you=20
close the file and "fix" it... but the file still seems to close!
I find ANOTHER spot where you close it, and remove that one too...
but the file STILL won't behave.

If we had a SINGLE approach which was reliable and easy-to-use,=20
(which is, of course, what we're aiming for) couldn't we just use=20
that everywhere, and use it just once?

-- Michael Chermside