thanx ..I understand the problem now..<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 14, 2012 at 7:48 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a>></span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><div class="im">On 2012-11-14 15:18, inshu chauhan wrote:<br>

<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<br>
for this code m getting this error :<br>
<br>
CODE :<br>
def ComputeClasses(data):<br>
     radius = .5<br>
     points = []<br>
     for cy in xrange(0, data.height):<br>
         for cx in xrange(0, data.width):<br>
             if data[cy,cx] != (0.0,0.0,0.0):<br>
                 centre = data[cy, cx]<br>
                 points.append(centre)<br>
<br>
<br>
</blockquote></div>
Look at this line:<br>
<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
             change = True<br>
<br>
</blockquote>
It's indented the same as the preceding 'if' statement, which means<br>
that it's executed even if the body of the 'if' statement wasn't<br>
executed and it hasn't assigned to 'centre'.<br>
<br>
So 'change' has been set to True, the 'while' loop is entered, and<br>
subsequently an attempt is made to get 'centre', which hasn't been set.<div class="im"><br>
<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
             while change:<br>
<br>
                 for ring_number in xrange(1, 1000):<br>
                     change = False<br>
                     new_indices = GenerateRing(cx, cy, ring_number)<br>
<br>
<br>
                     for idx in new_indices:<br>
                         point = data[idx[0], idx[1]]<br>
<br>
                         if point == (0.0, 0.0, 0.0 ):<br>
                           continue<br>
                         else:<br>
                             dist = distance(centre, point)<br>
                             if  dist < radius :<br>
                                 print point<br>
                                 points.append(point)<br>
                                 change = True<br>
                                 print change<br>
<br>
<br>
</blockquote></div>
The indentation of this line looks wrong to me:<br>
<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
             break <br></blockquote></blockquote><div> </div><div> </div><div>But If I change the indentation of break towards inside, its going into infinite loop.. ???  </div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<br>
</blockquote>
It'll affect the 'for cx' loop at the end of its first iteration, every<br>
time.<div class="HOEnZb"><div class="h5"><br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<br>
ERROR :<br>
Traceback (most recent call last):<br>
   File "Z:\modules\classification2.<u></u>py", line 74, in <module><br>
     ComputeClasses(data)<br>
   File "Z:\modules\classification2.<u></u>py", line 56, in ComputeClasses<br>
     dist = distance(centre, point)<br>
UnboundLocalError: local variable 'centre' referenced before assignment<br>
<br>
And i am unable to understand .. WHY ?<br>
<br>
</blockquote>
<br></div></div><span class="HOEnZb"><font color="#888888">
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>