[Python-Dev] Must objects with enter/exit also supply context? (original) (raw)

Phillip J. Eby pje at telecommunity.com
Wed Apr 26 02:19:04 CEST 2006


At 04:18 PM 4/25/2006 -0700, Guido van Rossum wrote:

But the question remains, under what circumstances is it convenient to call context() explicit, and pass the result to a with-statement?

Oh. I don't know of any; I previously asked the same question myself. I just eventually answered myself with "I don't care; we need to require self-returning context on execution context objects so that the documentation can appear vaguely sane." :)

So, I don't know of any non-self-returning use cases for context on an object that has enter and exit. In fact, I suspect that we could strengthen the requirements to say that:

  1. If you have enter and exit, you MUST have a self-returning context

  2. If you don't have enter and exit, you MUST NOT have a self-returning context

#2 is obvious since you can't use the object with "with" otherwise. #1 reflects the fact that it doesn't make any sense to take the context of a context.



More information about the Python-Dev mailing list