A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-April/064359.html below:

[Python-Dev] Must objects with __enter__/__exit__ also supply __context__?

[Python-Dev] Must objects with __enter__/__exit__ also supply __context__? [Python-Dev] Must objects with __enter__/__exit__ also supply __context__?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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4