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


Groups > comp.lang.python > #49078

Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.064
X-Spam-Evidence '*H*': 0.88; '*S*': 0.01; 'subject:code': 0.07; 'contexts': 0.09; 'executed': 0.09; 'explanation': 0.09; 'cc:addr :python-list': 0.11; 'subject: \n ': 0.16; 'subject:variable': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'bit': 0.19; 'cc:addr:python.org': 0.22; "shouldn't": 0.24; 'sorry,': 0.24; 'cc:2**0': 0.24; '(see': 0.26; 'right.': 0.26; 'header:In-Reply- To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'comments': 0.31; 'problem': 0.35; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'programming,': 0.36; "i'll": 0.36; 'being': 0.38; 'called': 0.40; 'new': 0.61; 'matter': 0.61; 'john': 0.61; "you're": 0.61; 'within': 0.65; 'subject:this': 0.83; 'is)': 0.84; 'subject:before': 0.84; 'to:addr:gordon': 0.84; 'tricky': 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 :cc:content-type; bh=i7ygN32qmfULIaXkwnH8aUmIcRztUcHkmfUa1UXgKgo=; b=gxfLTTzm2LG5oRPZYOmuz7+cXLXBqxT8q0WNMcCA8QWqpPkZfqfYIBVUbRkPs2nQKh 0hXHu7uqHCzz9jokeBbCV0zbMl/Je01vTliDFphIkuDx3wdj4kV/j6f6huLLIkFKFm9S 10BK8SdgRVEeVeLqMkLilQ2Ct0UTGoM77QI6aw4Cx3ukxhX2pVQheDRMzPJ9PvPr3ePx SX3V0+w6k4gq6LpgHMU+g4f5TlNjn+LGsYEaF65xetQgr2Fe0dRLtDf0a0mkE16N7u6e 5dErtJKTqeOXfAuP6an4BIYhuJ8rTe68rvRv6qyDkOKUAPX32+RlwpbIcF03zWvWEmHj VQ/g==
X-Received by 10.152.120.228 with SMTP id lf4mr12321201lab.65.1372106040230; Mon, 24 Jun 2013 13:34:00 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <kqa981$9uu$1@reader2.panix.com>
References <b3d3518a-f24a-4c32-a41a-b99145753528@googlegroups.com> <kqa981$9uu$1@reader2.panix.com>
From Joshua Landau <joshua.landau.ws@gmail.com>
Date Mon, 24 Jun 2013 21:33:19 +0100
Subject Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)
To John Gordon <gordon@panix.com>
Content-Type text/plain; charset=UTF-8
Cc python-list <python-list@python.org>
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3763.1372106041.3114.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372106041 news.xs4all.nl 15992 [2001:888:2000:d::a6]:51772
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49078

Show key headers only | View raw


On 24 June 2013 21:12, John Gordon <gordon@panix.com> wrote:
> Since you're new to programming, this might be a bit tricky to explain,
> but I'll do my best. :-)
>
> The problem is that change() isn't being executed here; instead it's being
> executed from within root.mainloop(), whenever the user presses button-1.
>
> And within root.mainloop(), there is no variable called isWhite.

Sorry, but I don't think you're right. Functions "carry" their
contexts around with them, so that shouldn't matter

(See Peter and Antoon's comments for explanation of what I think it is)

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


Thread

What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) pablobarhamalzas@gmail.com - 2013-06-24 12:47 -0700
  Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) pablobarhamalzas@gmail.com - 2013-06-24 12:53 -0700
  Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) Peter Otten <__peter__@web.de> - 2013-06-24 22:05 +0200
  Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-06-24 22:10 +0200
  Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) John Gordon <gordon@panix.com> - 2013-06-24 20:12 +0000
    Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-24 21:33 +0100
    Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) Dave Angel <davea@davea.name> - 2013-06-24 16:43 -0400
      Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) John Gordon <gordon@panix.com> - 2013-06-24 21:41 +0000
  Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) pablobarhamalzas@gmail.com - 2013-06-24 13:19 -0700
    Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-24 21:33 +0100
  Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-24 21:19 +0100

csiph-web