Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.057 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'attribute': 0.07; 'correct.': 0.07; 'def': 0.12; 'naming': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'work,': 0.20; '>>>': 0.22; 'example': 0.22; 'looks': 0.24; 'this:': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; "doesn't": 0.30; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'noticed': 0.34; 'could': 0.34; 'connection': 0.35; 'received:google.com': 0.35; 'consistent': 0.36; 'object,': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'ian': 0.60; 'places': 0.64; 'jul': 0.74; 'ethan': 0.84; 'furman': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=i96cVJK9qLoOJCSy3GwHITKGayNhyijMr+KYT4PUy70=; b=dptxaxk7bplsAcw2mMYgA3GDoo/NU2OsZeP8hSVafunpGboEm6owJ+XmTwwR8Vq4Om KdNSDd3fZYBFJK/INTokAa1Atjj2OsaIG1Vx2rcEXvOiGtKRxE9ATsN/KaKmkgT6y5Xg l0nUGz+QT3rBBvboSKafrWgEqvDlZyOYWC/KvXF17fC8WZA665CHKt6rqA9Qum5BOL6q 79a8OiG68C4Bf092+2Ym2e4UDlPy4uY8VWQQpc3EKwKh2AEPdWYtC/vj6gDF1/yyp0ui LOxDsrCab9LYpnTKybLacj1xCB8yUSww1p4c2IGKb7CeBzQz+M2AVT6VdCsm85ORHEgG F7vg== X-Received: by 10.68.90.3 with SMTP id bs3mr19875730pbb.158.1373395310938; Tue, 09 Jul 2013 11:41:50 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <51DC472E.3090806@stoneleaf.us> References: <51d4eb9c$0$29999$c3e8da3$5496439d@news.astraweb.com> <51d508ed$0$6512$c3e8da3$5496439d@news.astraweb.com> <51d5a504$0$29999$c3e8da3$5496439d@news.astraweb.com> <51DC355E.20606@stoneleaf.us> <51DC472E.3090806@stoneleaf.us> From: Ian Kelly Date: Tue, 9 Jul 2013 12:41:10 -0600 Subject: Re: Default scope of variables To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373395321 news.xs4all.nl 15963 [2001:888:2000:d::a6]:51968 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50269 On Tue, Jul 9, 2013 at 11:23 AM, Ethan Furman wrote: > On 07/09/2013 09:44 AM, Ian Kelly wrote: >> >> On Tue, Jul 9, 2013 at 10:07 AM, Ethan Furman wrote: >>> >>> You could also do it like this: >>> >>> def updating(self): >>> self.transaction_active = True >>> return self >> >> >> Yes, that would be simpler. I was all set to point out why this >> doesn't work, and then I noticed that the location of the >> "transaction_active" attribute is not consistent in the original code. >> The DbSession class places it on self, and then the example usage >> places it on the connection object > > > It looks like DbSession has a conn object, and in the example he has > DbSession() named as conn -- ironic, considering this is a variable scoping > thread. ;) The object returned by __enter__ is the conn object, not the DbSession, so naming it "conn" is correct.