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


Groups > comp.lang.python > #33343

Re: Error

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'run,': 0.07; 'subject:Error': 0.07; 'referenced': 0.09; 'cc:addr:python- list': 0.10; 'def': 0.10; '0.0,': 0.16; '1000):': 0.16; 'dist': 0.16; 'idx': 0.16; 'wed,': 0.16; 'wrote:': 0.17; '&lt;': 0.17; 'variable': 0.20; 'email addr:gmail.com&gt;': 0.20; 'skip:" 30': 0.20; 'assignment': 0.22; 'received:74.125.82.174': 0.23; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; '(most': 0.27; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'run': 0.28; 'url:mailman': 0.29; 'points': 0.29; 'skip:& 10': 0.29; 'error': 0.30; 'code': 0.31; 'point': 0.31; 'url:python': 0.32; 'file': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'getting': 0.33; 'received:74.125.82': 0.33; 'traceback': 0.33; 'true.': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'nov': 0.35; 'continue': 0.35; 'received:74.125': 0.36; 'url:org': 0.36; "wasn't": 0.36; 'test': 0.36; 'skip:p 20': 0.36; 'unable': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'header:Received:5': 0.40; 'url:mail': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'skip:\xc2 10': 0.62; '8bit%:100': 0.70; '74,': 0.91; 'joel': 0.91; 'to:none': 0.93
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=jlMtEb759Gqd2ymuxrK9v8NKRPCOGanxgb/vryhcR5M=; b=d0Zb8P7V3+5NV7JQuCB0e6i5ad9beiNt9eAe6BhePwm/ArC4kHdSeGHQbWYW8Qzbdq ga06jc6nefJMVu7huNn4UERJ/2NBqFgj76gxXKly1EuuvgsWTA37BOUOGNi7V8L1t3j7 L+jZxAIwfZupRu9unk9DfT+iCsJii7u+4MUXTIsCZ/+0d4o0tyLVY88QA+B7/A+xRqC9 9Dpf3M9tmU0Sd3NYNI3dqvdOh+5JsjMUxgrpZO7G3niqJ/MinxKufQuzErvBshpF81lm BL78TyHacDLAJRzT3HyL2xdgM7LETPlxKNdrpJ2GDZmH6KSTpK89YYBA5scyBBfNG+U3 p2Cg==
MIME-Version 1.0
In-Reply-To <CAFqGZRGYDM_3H657gid9GUxrSbnM_92nCZEsWWcWhFua5xEpmw@mail.gmail.com>
References <CAFqGZRGYDM_3H657gid9GUxrSbnM_92nCZEsWWcWhFua5xEpmw@mail.gmail.com>
Date Wed, 14 Nov 2012 11:02:34 -0500
Subject Re: Error
From Joel Goldstick <joel.goldstick@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type multipart/alternative; boundary=f46d0444ec31acf30a04ce76a91a
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.3689.1352908956.27098.python-list@python.org> (permalink)
Lines 135
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352908956 news.xs4all.nl 6959 [2001:888:2000:d::a6]:55899
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33343

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Wed, Nov 14, 2012 at 10:18 AM, inshu chauhan <insideshoes@gmail.com>wrote:

>
> for this code m getting this error :
>
> CODE :
> def ComputeClasses(data):
>     radius = .5
>     points = []
>     for cy in xrange(0, data.height):
>         for cx in xrange(0, data.width):
>             if data[cy,cx] != (0.0,0.0,0.0):
>
This code is only run if the test above is true

>                 centre = data[cy, cx]
>                 points.append(centre)
>
>
>             change = True
>
>             while change:
>
>                 for ring_number in xrange(1, 1000):
>                     change = False
>                     new_indices = GenerateRing(cx, cy, ring_number)
>
>
>                     for idx in new_indices:
>                         point = data[idx[0], idx[1]]
>
>                         if point == (0.0, 0.0, 0.0 ):
>                           continue
>                         else:
>                             dist = distance(centre, point)
>
centre is only set if the test above is true.  In your run, it apparently
wasn't

>                             if  dist < radius :
>                                 print point
>                                 points.append(point)
>                                 change = True
>                                 print change
>
>
>             break
>
>
> ERROR :
> Traceback (most recent call last):
>   File "Z:\modules\classification2.py", line 74, in <module>
>     ComputeClasses(data)
>   File "Z:\modules\classification2.py", line 56, in ComputeClasses
>     dist = distance(centre, point)
> UnboundLocalError: local variable 'centre' referenced before assignment
>
> And i am unable to understand .. WHY ?
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>


-- 
Joel Goldstick

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


Thread

Re: Error Joel Goldstick <joel.goldstick@gmail.com> - 2012-11-14 11:02 -0500

csiph-web