Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'assignment': 0.07; 'function,': 0.09; 'will,': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; '"global"': 0.16; 'exist.': 0.16; 'globals.': 0.16; 'increment': 0.16; 'local.': 0.16; 'scope.': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'url:python': 0.33; 'problem': 0.35; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'clear': 0.37; 'nov': 0.38; 'issue': 0.38; 'url:mail': 0.40; 'read': 0.60; 'analysis,': 0.60; 'name': 0.63; 'sharing': 0.69; 'joel': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=Qe+aNL/HNYoDW8kX9QDBcosl2+JtUTQGKX/xb8tAa9M=; b=fVGrd1otExt6tFJkey7XRfJOdWQ8L6ACXOQsQzk7I1w1fOMLimLGCU0hSkI5VDWzDs prGEpTG2ChP9SEmIFjRcgDUwXYbuF0KNN09w5kwEtOoQ/LiLDlcXZCdKRqVhlg3YYFrK TBHQoaOriymJjVM3UYcLEU1gvawR98obXM4YkCXTwHjUuxri0cRyTfACq89vBWHL368n ghDBaPvd3LpY2OHw0kdEwzN87c7iPYT6OmCxtMJ6LOK6JzdEFUHQQgLSAZ2ck08vU8ou 0cQF1YSQiQusyUqiOs6MOBK0l3ZHCG6WIkKeJdGAI4bMZiWX8rDa7lSypy4QJX+TX9Di w1tQ== MIME-Version: 1.0 X-Received: by 10.224.76.3 with SMTP id a3mr45224014qak.31.1415633249954; Mon, 10 Nov 2014 07:27:29 -0800 (PST) In-Reply-To: References: Date: Mon, 10 Nov 2014 10:27:29 -0500 Subject: Re: A syntax question From: Joel Goldstick Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 1415633253 news.xs4all.nl 2947 [2001:888:2000:d::a6]:45876 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80470 On Mon, Nov 10, 2014 at 9:54 AM, Chris Angelico wrote: > On Tue, Nov 11, 2014 at 1:35 AM, Joel Goldstick > wrote: >> Your problem is that count is not local. You are reading count from >> an outer scope. When you try to increment count in your function, it >> can't because it doesn't exist. >> Don't use globals. > > False analysis, I'm afraid. The problem is that the assignment will, > in the absence of a "global" declaration, cause the name "count" to > indicate a local variable - so it won't ever be read from outer scope. > However, the OP's issue is better solved by sharing tracebacks than by > us peering into crystal balls; mine's showing a very clear image at > the moment, but it might well be incorrect. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list Interesting. Thanks for pointing that out -- Joel Goldstick http://joelgoldstick.com