Raymond Hettinger wrote:
Whatever term is selected, it should be well thought-out and added to the glossary. The choice of words will likely have a great effect on learnability and on how people think about the new tool.
When writing PEP 346, I ended up choosing "user defined statement" as a generic term for the sundry ways that the 'with' statement could be used. Signal blocking, exception logging, transactions, resource management, etc. . .
For me, the key point was that to understand what a 'with' statement is really doing, you needed to understand the behaviour of the supplied object. This is far less the case with other compound Python statements.
For 'if' statements and 'while' loops, the supplied object will always be interpreted as a boolean. In 'for' loops, the supplied object is guaranteed to return a series of other objects. An 'except' clause always expects an exception type of some description.
For 'with' statements, all we really know is that the object may do something before the suite it is entered, and something else as the suite is exited. Other than that, it could be (or do) anything. Hence, 'user defined statement'.
With that piece of terminology in place, the natural outcome was to call objects that supplied __enter__ and __exit__ methods "statement templates".
I also used this term to come up with PEP 346's name for the generator to statement template conversion decorator: "stmt_template"
(Like others, the fact that 'with' is a verb makes it very hard for me to interpret "with_template" correctly when I see it as a decorator - I always want to ask "with which template?")