Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.009 X-Spam-Evidence: '*H*': 0.98; '*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; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 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; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'problem': 0.35; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'clear': 0.37; 'nov': 0.38; 'issue': 0.38; '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=55f7URV8zf50PwiWmJkxHtyfhD7opIB8ELjwq51DDoY=; b=TN7gDdQKfH9eHRbgi21MCsV3fwcugGXbWuyqEqLXm7vP4WUlJE404nXdLeRHRNXtXx xFacYj3pjVvtIBXLFhQ827jobT2CjTyHCwTDu8fagzpgd2c82msh6qflp84g5mqIXzvp 02kQttn0hQJlpQDGb45n1GUVcQS1dZJFIMLLto6Sz2oPtreMyL21IqxiLSIG8Gg0Ia+C tZobhc0Ge2RPdO7CrrysgVYEZoiBcxWLgRk61lAnJ20aSZ708t2yGpJd9fC7aoEwNcNr 74sUNVNF+YSdz+l1vjrMi2t8eEzsSLYZISOKr2Ioyy9DblIWe4a2PlTwgRdIgqjv4NI2 Au5g== MIME-Version: 1.0 X-Received: by 10.50.136.134 with SMTP id qa6mr25543161igb.2.1415631242767; Mon, 10 Nov 2014 06:54:02 -0800 (PST) In-Reply-To: References: Date: Tue, 11 Nov 2014 01:54:02 +1100 Subject: Re: A syntax question From: Chris Angelico 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415631252 news.xs4all.nl 2952 [2001:888:2000:d::a6]:33760 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80466 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