> > The mechanism is more general than resource > >management. Like decorators, the encapsulation of a try/finally wrapper > >is completely generic and not married to the resource management > >context.
[Phillip] > Expand your mind. :) "Resource" can include whatever objects you want it > to -- or no objects at all. There is no value in expanding a concept to the point of being meaningless (i.e. meaning whatever you want it to or nothing at all). Instead, we need a phrase that expresses the essence of the following: abc = EXPR exc = (None, None, None) VAR = abc.__enter__() try: try: BLOCK except: exc = sys.exc_info() raise finally: abc.__exit__(*exc) There is nothing in that that says resource managed. The pre/post steps could do almost anything from logging, to changing environments, to translating, launching/joining unrelated threads, to communicating with other processes, etc. Ideally, the phrase needs to fit in a list of all of the other properties of the abc object (i.e. abc objects are callable, iterable, support the buffer interface, and are withable or somesuch). Another trouble with "resource managed" is that it makes little sense even when describing something that is clearly a resource (for instance, "locking objects are resource managed", what the heck could that mean, there is no hint about the presence of __enter__ and __exit__ or the ability to work with the "with" keyword). The phrase does nothing but suggest a particular application that historically has been implemented without the new mechanism. Of course, what makes this exercise hard is that our two new keywords are prepositions and the process that they apply to is somewhat abstract. Raymond P.S. I would still like to encourage the adoption of __leave__ instead of __exit__. The first suggests part of an enter/leave pair. The latter could too easily be taken as a standalone. If everyone doesn't see the subtle reasons why __leave__ is better, then at least consider __beginwith__ and __endwith__ which say exactly what they mean and are obviously paired with each other and with the new keyword. Remember, these methods are going to show up in objects such as Context which are not primarily about 343. All of the other methods names will have nothing to do with 343, so our choice of magic names needs to be really good (as there will likely be NO contextual hints). _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com