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


Groups > comp.lang.python > #33612 > unrolled thread

Re: Index Error

Started byChris Angelico <rosuav@gmail.com>
First post2012-11-21 00:48 +1100
Last post2012-11-21 00:48 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Index Error Chris Angelico <rosuav@gmail.com> - 2012-11-21 00:48 +1100

#33612 — Re: Index Error

FromChris Angelico <rosuav@gmail.com>
Date2012-11-21 00:48 +1100
SubjectRe: Index Error
Message-ID<mailman.50.1353419318.29569.python-list@python.org>
On Wed, Nov 21, 2012 at 12:43 AM, inshu chauhan <insideshoes@gmail.com> wrote:
> I need help in this part as I am unable to device a method in which if the
> points are out of index,it should stop.....
>
> Traceback (most recent call last):
>   File "Z:/modules/Classify.py", line 73, in <module>
>     ComputeClasses(data)
>   File "Z:/modules/Classify.py", line 49, in ComputeClasses
>     point = data[idx[0], idx[1]]
> error: index is out of range
>

When Python throws an exception, you can catch it and handle it as you
please. In this instance, it seems to me you want to break out of one
loop (if I've read your comments correctly), so just bracket that loop
with try... except. Start here:

http://docs.python.org/3.3/tutorial/errors.html

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web