Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed4.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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '"this': 0.03; 'subject:code': 0.07; 'cc:addr:python-list': 0.11; 'def': 0.12; '*never*': 0.16; 'closures': 0.16; 'false:': 0.16; 'problem!': 0.16; 'subject: \n ': 0.16; 'subject:variable': 0.16; 'pfxlen:0': 0.19; "python's": 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; '(this': 0.29; 'message- id:@mail.gmail.com': 0.30; 'could': 0.34; 'subject:with': 0.35; 'test': 0.35; 'received:google.com': 0.35; 'little': 0.38; 'sure': 0.39; 'most': 0.60; 'to:addr:gmail.com': 0.65; 'subject:this': 0.83; 'confusing': 0.84; 'subject:before': 0.84 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=Xs/PbUL07Rs/fuKJvEawQX9HIZqf7DxG7Y793BAbsaw=; b=EAQZ2z7M+OL7tDmDXooObObh/mr/Ovu80ChsH3MN70kGtJ1Sq+1qkX8YVoWzaxn8NF yqG677AwNgkT/1XT6dcccF5PQBLvVO7GIsaHOKQRCTmgyhk3kAQGC9/m25765teNHKbf UxW8htuQIzbDh6/W+sdOx4tW1ZW3LUSrXdhnKDSocLHnZIAU3qbOL3IP0Oxoz6ZWrTqb V+0xLh3cI8XSRNxrmonEVDimasDMGwwwTsAizquJ9EhL8Z8NPPl/sneQVg9zow0rNO5z H2bST4ixuO96iM5wxbJrqz64TpDun493f2/Wq2h0wZQ8dMOYN/IoyrL0fY93Z675WTc+ GaQA== X-Received: by 10.152.4.232 with SMTP id n8mr12300457lan.29.1372105181741; Mon, 24 Jun 2013 13:19:41 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Joshua Landau Date: Mon, 24 Jun 2013 21:19:01 +0100 Subject: Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment) To: pablobarhamalzas@gmail.com Content-Type: text/plain; charset=UTF-8 Cc: python-list 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372105516 news.xs4all.nl 15985 [2001:888:2000:d::a6]:45723 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49077 Here's a little test to make sure you understand (this is one of the most confusing parts of Python's closures in my opinion): foo = "I'm foo!" def working(): print(foo) def broken(): print(foo) if False: # There's no way this could cause a problem! foo = "This will *never* happen"