Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'context': 0.04; 'skip': 0.04; 'completeness': 0.05; 'cached': 0.07; 'to:name:python- list@python.org': 0.15; '712': 0.16; '>with': 0.16; 'currencies': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:169.70': 0.16; 'received:169.70.184': 0.16; 'received:169.70.184.72': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:hubcr105.exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'subject:alternative': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wrote:': 0.18; 'previously': 0.19; 'slightly': 0.19; 'seems': 0.20; 'trying': 0.21; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'statement': 0.23; 'pep': 0.23; '(like': 0.26; 'received:169': 0.28; 'received:169.254': 0.28; "i'm": 0.28; 'odd': 0.29; 'down,': 0.30; 'received:155': 0.30; 'received:159': 0.30; 'subject:?': 0.31; 'accuracy': 0.32; 'there': 0.33; 'file': 0.34; 'header:Received:8': 0.34; 'elegant': 0.34; 'to:addr:python-list': 0.35; 'phone:': 0.35; 'charset:us- ascii': 0.37; 'subject:with': 0.37; 'think': 0.38; 'that.': 0.39; 'point': 0.40; 'to:addr:python.org': 0.40; 'subject': 0.61; 'offers': 0.62; 'here': 0.64; 'information,': 0.69; 'legal': 0.72; 'url:email': 0.72; 'bank': 0.75; 'sale': 0.75; 'investment': 0.77; 'purchase': 0.78; 'alternative.': 0.84; 'received:169.254.8': 0.84; 'craig': 0.91 X-DKIM: OpenDKIM Filter v2.1.3 sz1.jpmchase.com q1SMD2Vq018959 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=jpmorgan.com; s=smtpout; t=1330467182; bh=J+sY6o/9+hYM/QJTi5hQzG2+FDuO7iNI+HDeujDnZpQ=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=bxqvchRoOtShLbSNDXPXCHdig/ncqIIuyd9v34+CBm2I9owRxKD2EB8jTw3NQxPJL pPEjjHMU835xp74RhlXm55fkSOaC5furxIlHLft+N3BLMGtKn1g6vTJ2zejx4xtwOr wzy+gDqwdn5UTmbVcaWOCZ59ufgR7f+3fMLQc7hE= From: "Prasad, Ramit" To: "python-list@python.org" Subject: RE: alternative to with statement? Thread-Topic: alternative to with statement? Thread-Index: AQHM9mUZrCbImGGmZEqaYkPhLV5yHJZS3kqg Date: Tue, 28 Feb 2012 22:12:45 +0000 References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.38] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes Content-Type: text/plain; charset="us-ascii" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330467191 news.xs4all.nl 6873 [2001:888:2000:d::a6]:52391 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:21007 Craig Yoshioka wrote:=0D=0A>I see that there was previously a PEP to allow = the with statement to skip the enclosing block=2E=2E=2E this was shot down,= and I'm trying to think of the most elegant alternative=2E [=2E=2E]=0D=0A= =0D=0A>I would have really liked:=0D=0A>with cachingcontext(x):=0D=0A> #= create cached resources here=0D=0A># return cached resources=0D=0A=0D=0AIs= this a common pattern? I thought the point of the context manager =0D=0Awa= s to remove create and close the resources (like with file opening)=2E=0D= =0ASeems slightly odd to use just for creation=2E=2E=2Ebut maybe only becau= se=0D=0AI have never used it like that=2E=0D=0A=0D=0A=0D=0ARamit=0D=0A=0D= =0A=0D=0ARamit Prasad | JPMorgan Chase Investment Bank | Currencies Technol= ogy=0D=0A712 Main Street | Houston, TX 77002=0D=0Awork phone: 713 - 216 - 5= 423=0D=0A=0D=0A--=0D=0A=0D=0AThis email is confidential and subject to impo= rtant disclaimers and=0D=0Aconditions including on offers for the purchase = or sale of=0D=0Asecurities, accuracy and completeness of information, virus= es,=0D=0Aconfidentiality, legal privilege, and legal entity disclaimers,=0D= =0Aavailable at http://www=2Ejpmorgan=2Ecom/pages/disclosures/email=2E