diff options
author | Guido van Rossum <guido@python.org> | 2006-05-02 19:47:52 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2006-05-02 19:47:52 +0000 |
commit | da5b701aeef755f2317a41e36cc950cfdc0c95cb (patch) | |
tree | 11a37e4e8714ffbccce921aa0ef1878b7dc779b2 /Lib/contextlib.py | |
parent | 8f6cbe150228f175b57b7a774d0a630febe72244 (diff) | |
download | cpython-git-da5b701aeef755f2317a41e36cc950cfdc0c95cb.tar.gz |
Get rid of __context__, per the latest changes to PEP 343 and python-dev
discussion.
There are two places of documentation that still mention __context__:
Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without
spending a whole lot of time thinking about it; and whatsnew, which Andrew
usually likes to change himself.
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r-- | Lib/contextlib.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py index 4e3b9c2d38..9d2c6a3a14 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -10,9 +10,6 @@ class GeneratorContext(object): def __init__(self, gen): self.gen = gen - def __context__(self): - return self - def __enter__(self): try: return self.gen.next() @@ -88,7 +85,7 @@ def contextfactory(func): @contextfactory -def nested(*contexts): +def nested(*managers): """Support multiple context managers in a single with-statement. Code like this: @@ -109,8 +106,7 @@ def nested(*contexts): exc = (None, None, None) try: try: - for context in contexts: - mgr = context.__context__() + for mgr in managers: exit = mgr.__exit__ enter = mgr.__enter__ vars.append(enter()) @@ -152,8 +148,6 @@ class closing(object): """ def __init__(self, thing): self.thing = thing - def __context__(self): - return self def __enter__(self): return self.thing def __exit__(self, *exc_info): |