Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80466

Re: A syntax question

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 <rosuav@gmail.com>
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 <CAPM-O+zDYxr-EVJtiC92R-VfGvr33ByZ1jkVdkEPdgbv0CVdog@mail.gmail.com>
References <m3q6ae$m8p$1@news.albasani.net> <m3q84d$6is$1@ger.gmane.org> <CAPM-O+zDYxr-EVJtiC92R-VfGvr33ByZ1jkVdkEPdgbv0CVdog@mail.gmail.com>
Date Tue, 11 Nov 2014 01:54:02 +1100
Subject Re: A syntax question
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15624.1415631252.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Tue, Nov 11, 2014 at 1:35 AM, Joel Goldstick
<joel.goldstick@gmail.com> 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

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

A syntax question Mok-Kong Shen <mok-kong.shen@t-online.de> - 2014-11-10 12:07 +0100
  Re: A syntax question alister <alister.nospam.ware@ntlworld.com> - 2014-11-10 11:23 +0000
    Re: A syntax question David Palao <dpalao.python@gmail.com> - 2014-11-10 12:31 +0100
      Re: A syntax question Grant Edwards <invalid@invalid.invalid> - 2014-11-10 14:44 +0000
        Re: A syntax question alister <alister.nospam.ware@ntlworld.com> - 2014-11-10 14:54 +0000
          Re: A syntax question alister <alister.nospam.ware@ntlworld.com> - 2014-11-10 14:56 +0000
            Re: A syntax question Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-10 19:53 -0500
              Re: A syntax question alister <alister.nospam.ware@ntlworld.com> - 2014-11-11 09:04 +0000
          Re: A syntax question Grant Edwards <invalid@invalid.invalid> - 2014-11-10 16:11 +0000
            Re: A syntax question Chris Angelico <rosuav@gmail.com> - 2014-11-11 03:18 +1100
              Re: A syntax question Roy Smith <roy@panix.com> - 2014-11-10 14:48 -0500
    Re: A syntax question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-10 20:08 +0000
    Re: A syntax question Tim Chase <python.list@tim.thechases.com> - 2014-11-10 14:29 -0600
  Re: A syntax question Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-11-10 12:39 +0100
  Re: A syntax question Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-10 09:35 -0500
  Re: A syntax question Chris Angelico <rosuav@gmail.com> - 2014-11-11 01:54 +1100
  Re: A syntax question Peter Otten <__peter__@web.de> - 2014-11-10 16:10 +0100
  Re: A syntax question Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-10 10:27 -0500

csiph-web