Author serhiy.storchaka
Recipients benjamin.peterson, berker.peksag, eric.smith, mjpieters, python-dev, r.david.murray, serhiy.storchaka, vajrasky, vstinner
Date 2015-01-05.10:16:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420453012.31.0.857144419443.issue18644@psf.upfronthosting.co.za>
In-reply-to
Content
I prefer the current code (i.e. formatter_fix_resource_warning_v5.patch).

In more complex case ExitStack can be used, but here it looks redundant.

    with contextlib.ExitStack() as stack:
        if some_test:
            fl = open(sys.argv[1])
            stack.enter_context(fl)
        else:
            fl = sys.stdin
        do_stuff(fl)

or

    if some_test:
        cm = fl = open(sys.argv[1])
    else:
        fl = sys.stdin
        cm = contextlib.ExitStack()
    with cm:
        do_stuff(fl)
History
Date User Action Args
2015-01-05 10:16:52serhiy.storchakasetrecipients: + serhiy.storchaka, mjpieters, vstinner, eric.smith, benjamin.peterson, r.david.murray, python-dev, berker.peksag, vajrasky
2015-01-05 10:16:52serhiy.storchakasetmessageid: <1420453012.31.0.857144419443.issue18644@psf.upfronthosting.co.za>
2015-01-05 10:16:52serhiy.storchakalinkissue18644 messages
2015-01-05 10:16:52serhiy.storchakacreate