Context manager, atexit processing, and PEP 3143 DaemonContext.close

Ben Finney ben+python at benfinney.id.au
Mon May 18 17:39:57 EDT 2009


MRAB <google at mrabarnett.plus.com> writes:

> Gunter Henriksen wrote:
> > If there is a function which triggers a one-shot switch, I like to
> > have a way to find out if it has already been triggered, I prefer to
> > have the function tell me if it triggered the switch or not, but I
> > would not want that to be by raising an exception.
> 
> The 'file' class also has a 'closed' method, so that's a good model to
> follow.

Yes, I find that convincing as well. (I might prefer it to instead
answer the question “is it currently open?”, i.e. an ‘opened’ query,
but that makes for more awkward English than ‘closed’.)

-- 
 \           “Are you thinking what I'm thinking, Pinky?” “Uh... yeah, |
  `\     Brain, but where are we going to find rubber pants our size?” |
_o__)                                           —_Pinky and The Brain_ |
Ben Finney



More information about the Python-list mailing list