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


Groups > comp.lang.python > #33612

Re: Index Error

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'error:': 0.05; '21,': 0.07; 'subject:Error': 0.07; 'python': 0.09; 'exception,': 0.09; 'throws': 0.09; 'index': 0.13; '49,': 0.16; 'bracket': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:Index': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'instance,': 0.17; 'received:209.85.214.174': 0.21; "i've": 0.23; 'seems': 0.23; 'device': 0.24; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; '(most': 0.27; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'points': 0.29; 'point': 0.31; 'url:python': 0.32; 'file': 0.32; 'comments': 0.33; 'traceback': 0.33; 'handle': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'nov': 0.35; 'received:209.85': 0.35; 'url:org': 0.36; 'method': 0.36; 'should': 0.36; 'unable': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'range': 0.60; 'here:': 0.62; 'url:tutorial': 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:to :content-type; bh=uz4FNuNkpSo9tLBlizVv7z/0OMIAQDx/TqVC123bYKc=; b=Ci7mwulvN1lJYvkI/4M+NPJGq3R3FDAX/suTa431rO+nJqKqsYj0hi6pWwRo812PMx B6ImeSfaAu+LY01oME8VJyguIC5Vs8R40fMvtl8cq9gDu2DPQKmGWyLeVimzpzpVppqk BD21L2blB0+8r1+6leAcxNqwekMeQ9auRvg6X6zYhsMdUQr+K55O09ftSMGLulOePl4Y RHZV6t/4W9oyVW2DE/YwFsdZBqsovLz4tRnMTUgm0p3+xJhjdmZNO2xBd8zsc3fyHiJo 6Mm1QAgc+aLteGbQGOBoKG+QFvQeDo5x3XbIYdoYdIzMQT+vgPC3TWZfxlj3EQFnvwgx rWQA==
MIME-Version 1.0
In-Reply-To <CAFqGZRHSZ2QTqw=_iZWCWVJXVoxEZvHkTEmb-QeohRer2hjj7w@mail.gmail.com>
References <CAFqGZRHSZ2QTqw=_iZWCWVJXVoxEZvHkTEmb-QeohRer2hjj7w@mail.gmail.com>
Date Wed, 21 Nov 2012 00:48:34 +1100
Subject Re: Index Error
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.50.1353419318.29569.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1353419318 news.xs4all.nl 6884 [2001:888:2000:d::a6]:54938
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33612

Show key headers only | View raw


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

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


Thread

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

csiph-web