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

Phillip J. Eby pje at telecommunity.com
Wed Apr 26 02:35:38 CEST 2006


At 05:20 PM 4/25/2006 -0700, Guido van Rossum wrote:

I would augment #1 to clarify that if you have enter and exit you may not have context at all; if you have all three, context must return self.

Well, requiring the context allows us to ditch the otherwise complex problem of why @contextfactory functions' return value is usable by "with", without having to explain it separately. So, I don't think there's any reason to provide an option; there should be Only One Way To Do It.

Well, actually, two. That is, you can have one method or all three. Two is right out. :)

(ObMontyPython: Wait, I'll come in again...)



More information about the Python-Dev mailing list