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


Groups > comp.lang.python > #65057

Why this throws an UnboundLocalError ?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <glicerinu@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.019
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'assignment': 0.07; 'referenced': 0.09; 'subject:Why': 0.09; 'python': 0.11; 'def': 0.12; '2.7.3': 0.16; 'subject: ?': 0.16; 'variable': 0.18; 'all,': 0.19; 'module': 0.19; '>>>': 0.22; 'import': 0.22; 'aug': 0.22; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; 'marc': 0.31; 'anyone': 0.31; 'file': 0.32; '(most': 0.33; 'received:google.com': 0.35; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'simple': 0.61; 'more': 0.64; 'dear': 0.65; 'subject:this': 0.83
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=DQYLsCUcc18TqSEwYu/gTMfUyu/e16v1FlYMmQ9ZhcE=; b=lTnZFLX/KkrbuztSjbpGN6SrUGkqr8PhJzueGFjD3Uy3ZEG/N9KRc5gki2XU+JtcJU +gA38Bg1IHN38BDgI7PEELANe1J52a3jGF0XT0Qb7qqD+xa3Ren/tTOsZzyUzbXsJ4Ip p8jRUngp/ZzxnRgN5Xsr1Qk0YkICZxdh63hAFRkKvdd+glwlBA7pEDncreQ5PrBzX1Yy obK6cm+vvSn/RkWLL+Dv0tHZvjPpXKLZ+cWZ6S9W9oC/e96ZrZcf4q8nNau/PdIawaE/ BWrhBYuTBCwXDUkHmuiiIdOsOSVSIdW34nIdvJYBj4DopB9jyYw6u+XIjHeq0wRhy5Tz lrTA==
X-Received by 10.153.3.2 with SMTP id bs2mr11253121lad.5.1391122037393; Thu, 30 Jan 2014 14:47:17 -0800 (PST)
MIME-Version 1.0
From Marc Aymerich <glicerinu@gmail.com>
Date Thu, 30 Jan 2014 23:46:57 +0100
Subject Why this throws an UnboundLocalError ?
To "comp.lang.python" <python-list@python.org>
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 <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.6172.1391122039.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391122039 news.xs4all.nl 2857 [2001:888:2000:d::a6]:40703
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65057

Show key headers only | View raw


Dear all,

I have a very simple module

glic3@e4200:# cat globalstate.py
GLOBAL = 0

def update():
    GLOBAL += 1


however it doesn't work!!

glic3@e4200:# python
Python 2.7.3 (default, Aug  1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import globalstate
>>> globalstate.update()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "globalstate.py", line 4, in update
    GLOBAL += 1
UnboundLocalError: local variable 'GLOBAL' referenced before assignment


And I don't know why :(
Anyone ?

Thanks!!
-- 
Marc

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


Thread

Why this throws an UnboundLocalError ? Marc Aymerich <glicerinu@gmail.com> - 2014-01-30 23:46 +0100

csiph-web