[Python-Dev] Terminology for PEP 343

Phillip J. Eby pje at telecommunity.com
Mon Jul 4 04:02:33 CEST 2005


At 03:04 PM 7/3/2005 +0100, Michael Hudson wrote:
>"Phillip J. Eby" <pje at telecommunity.com> writes:
>
> > At 05:41 PM 6/30/2005 -0400, Raymond Hettinger wrote:
> >>With 343 accepted, we can now add __enter__() and __exit__() methods to
> >>objects.
> >>
> >>What term should describe those objects in the documentation?
> >
> > Resource managers.
>
>Thing is, there may be no resource; in my talk at EuroPython:
>
>     http://starship.python.net/crew/mwh/recexc.pdf
>
>I used a with statement to establish and dis-establish an error
>handler -- would you call that a resource?

Yes; an error handling resource is no different than say, a decimal context 
resource in this respect.  A "with" statement defines the scope of use or 
applicability of some resource; the resource manager is the object that is 
notified as to when the scope is entered and exited, so that it can 
appropriately manage the resource.

Some resources may be their own default resource manager, but it's always 
possible to create a different resource management policy by creating a new 
resource manager.

I think this is a clear and straightforward explanation of what "with" does 
and what you can do with it.



More information about the Python-Dev mailing list