Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.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.158 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.71; '*S*': 0.02; 'attribute': 0.07; 'def': 0.12; 'wrote:': 0.18; 'code.': 0.18; 'work,': 0.20; 'seems': 0.21; 'example': 0.22; 'source': 0.25; 'this:': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'class': 0.32; 'another': 0.32; 'noticed': 0.34; 'could': 0.34; 'connection': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'consistent': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'places': 0.64; 'jul': 0.74; 'demonstrates': 0.84; 'ethan': 0.84; 'factoring': 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=ItpZpt9UqyBPMn10+j81of1UzQamvT9g7uFUWFlJLt8=; b=l4Be+8znR5fpWy+nJ6kNkR6098Ep+GiQA9msUlNJkdeKbIiqYNQO39ljI/JH+p17+t qKyz1ZvDIkHDco46Fdy63mzvwl3DuAYu3Kv+3XcGJ6ddE828SIOwzX+E9a7tfBrWVwag hoOGkVHbT5yGDNSJalMLxAhAyhsdy26yAoXXEZoUr/lwjkq0SwJl0zioh1RfifGqKmWh yZJa1BI8cq44DS4xNwCPTT3pVdlM+ZZFIbLCQM0Pe+3eGqWPEfuiWZpx2Nx27QrGEdqK vxBpndDS4KMkB5EKrMV6uoqi9hm4P64TIWh8IwUpHUZOD19wS4DeToWUTcRbqR66EZL7 eVyQ== X-Received: by 10.66.249.202 with SMTP id yw10mr28640259pac.145.1373388301795; Tue, 09 Jul 2013 09:45:01 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <51DC355E.20606@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> From: Ian Kelly Date: Tue, 9 Jul 2013 10:44:18 -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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373388305 news.xs4all.nl 16007 [2001:888:2000:d::a6]:51507 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50262 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 (which I had based my version on). Since that seems to be a source of confusion, it demonstrates another reason why factoring this out is a good thing.