This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Eric.Wieser
Recipients Eric.Wieser
Date 2013-04-18.10:02:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1366279360.22.0.996047925833.issue17788@psf.upfronthosting.co.za>
In-reply-to
Content
It would be nice if there was a `with` "expression". Such that instead of:

    with open(...) as f:
        result = foo(f)

One could write:

    result = foo(f) with open(...) as f

This would be particularly useful in comprehensions. Instead of:

    files = {}
    for fname in os.listdir('.'):
        if predicate(fname):
            with open(fname) as f:
                files[fname] = foo(f)

    files = {
        fname: foo(f) with open(fname) as f
        for fname in os.listdir('.') if predicate(fname)
    }
History
Date User Action Args
2013-04-18 10:02:40Eric.Wiesersetrecipients: + Eric.Wieser
2013-04-18 10:02:40Eric.Wiesersetmessageid: <1366279360.22.0.996047925833.issue17788@psf.upfronthosting.co.za>
2013-04-18 10:02:40Eric.Wieserlinkissue17788 messages
2013-04-18 10:02:40Eric.Wiesercreate