Index Error

inshu chauhan insideshoes at gmail.com
Tue Nov 20 10:01:44 EST 2012


>
>
> So did you read the following paragraphs?  You should not be using "and"
> in that expression.



> Yes i tried "or" also but no use .....
>
> >>
> >> You do not want "and" in that expression.  The way you've coded it,
> >> it'll only skip items in which both indices are out of range.  Change
> it to
> >>                   if idx[0] >= data.width or idx[1] >= data.height:
> >>
> >> and depending on your answer to my earlier query, you may want to also
> >> check if either subscript is negative.
> >>
> >>>                             continue
> >>>                         else :
> >>>                             point = data[idx[0], idx[1]]
> >>>                             if point == (0.0, 0.0, 0.0 ):
> >>>                                 print point
> >>>                                 continue
> >>>                             else:
> >>>                                 dist = distance(centre, point)
> >>>                                 print dist
> >>>                                 if  dist < radius :               and
> >> rings
> >>> should be added only when this condition is satisfied
> >>>                                     print point
> >>>                                     points.append(point)
> >>>                                     change = True
> >>>                                     print change
> >>>
> >>>
> >>>                         break
> >>
> >> Why do you want to terminate the loop after only iteration?
> >>
> >
> > I dint get your question ??
> >
>
> You have a break there.  What's it for?  It'll make sure you only
> process one of the idx values from new_indices.  i doubt that's what you
> intended.
>
The idea here is if no more point is added to the list of points i.e. all
points surrounding the centre is zero.. I want to break the loop and go to
the next point..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121120/5c2c05f1/attachment.html>


More information about the Python-list mailing list