A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-October/056970.html below:

[Python-Dev] PEP 343 and __with__

[Python-Dev] PEP 343 and __with__ [Python-Dev] PEP 343 and __with__Jason Orendorff jason.orendorff at gmail.com
Tue Oct 4 16:51:11 CEST 2005
Right after I sent the preceding message I got a funny feeling I'm
wasting everybody's time here.  I apologize.  Guido's original concern
about speedy C implementation for locks stands.  I don't see a good
way around it.

By the way, my expansion of 'with' using coroutines (in previous
message) was incorrect.  The corrected version is shorter; see below.

-j


This:

    with EXPR as VAR:
        BLOCK

would expand to this under PEP 342 and my proposal:

    _cm = (EXPR).__with__()
    VAR = _cm.next()
    try:
        BLOCK
    except:
        _cm.throw(*sys.exc_info())
    finally:
        try:
            _cm.next()
        except (StopIteration, GeneratorExit):
            pass
        else:
            raise RuntimeError("coroutine didn't finish")
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