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


Groups > comp.lang.python > #32816

Re: error

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'error:': 0.05; 'modified': 0.05; 'convention,': 0.09; 'definition,': 0.09; 'modifies': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'subject:error': 0.11; 'suggest': 0.11; 'index': 0.13; '0.0,': 0.16; '1):': 0.16; 'appends': 0.16; 'both.': 0.16; "function's": 0.16; 'height,': 0.16; 'modified.': 0.16; 'parameter,': 0.16; 'prog': 0.16; 'returned,': 0.16; 'traceback.': 0.16; 'wrote:': 0.17; "shouldn't": 0.17; 'obviously': 0.18; 'exceptions': 0.22; 'cc:2**0': 0.23; 'somebody': 0.23; 'second': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; 'in.': 0.27; "doesn't": 0.28; 'there.': 0.28; 'initial': 0.28; 'parameters.': 0.29; 'points': 0.29; 'class': 0.29; 'function': 0.30; 'error': 0.30; 'code': 0.31; 'point': 0.31; 'running': 0.32; 'getting': 0.33; 'list': 0.35; 'built-in': 0.35; 'returning': 0.35; 'sequence': 0.35; 'there': 0.35; 'created': 0.36; 'but': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'possible': 0.37; 'passed': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'comment': 0.38; 'received:192': 0.39; 'list,': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'range': 0.60; 'first': 0.61; 'show': 0.63; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'points,': 0.84; 'received:74.208.4.194': 0.84
Date Tue, 06 Nov 2012 08:05:50 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1
MIME-Version 1.0
To inshu chauhan <insideshoes@gmail.com>
Subject Re: error
References <CAFqGZRFPVdtXvEV0xMEDXG=7KCtKyNwd4Vq6VvDk3CPwW1n5fA@mail.gmail.com>
In-Reply-To <CAFqGZRFPVdtXvEV0xMEDXG=7KCtKyNwd4Vq6VvDk3CPwW1n5fA@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:BRSTJt/32NjqouPL3a3qbpxaOxa4gYUN7CuFxbu8OSf 1mhOSL0D1VGFZkHoxF9O3VlushishP5HIMwCnIruu6X86MAujx 474gWOb8F23eXGuDfuzq1p7WQpJW2MwFT7EYxFRSAzWtLlV5NG n5ZAe6TMHoYwEgZ1Ud03xidcoGvHJwoghKQoQghOPc1/olXNhX jiqSHFPblim1/VIi1PwegtE/ykJzmU0H/uolWUSYHvY3dykLk6 KEFNnMdf2E2TETOezAdCsm01PuraMI0w3JbzGJDLyKYRXL+Hzr QG8wZ4G0huRXbKfEqOTGFbxt244AUgeNCOto8YsSy+/I2tRFw= =
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
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.3320.1352207175.27098.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352207175 news.xs4all.nl 6919 [2001:888:2000:d::a6]:56112
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32816

Show key headers only | View raw


On 11/06/2012 07:31 AM, inshu chauhan wrote:
> I am getting this error while running my programme.. :
>
> error: index is out of range

Please paste the whole error, including the traceback.  It'll show you
the line that had the error, as well as the calling sequence that got
you there.

>
>  I cannot find a valid reason for it in my prog can somebody suggest what
> may be possible reasons for this error..
>
> The part of the code is :
>
> def addpoints (data, points, ix, iy): # makes a list of relevant points
>     if 0 < ix < data.width and 0 < iy < data.height:
>         point = data[ix, iy]

Tell us the type of the parameters.  Perhaps data is of type Zanzibar, 
and the first subscript is the height, and the second is the width? 
Show us your class definition, since data is obviously not a built-in
collection.

>         if point != (0.0, 0.0, 0.0):
>             points.append(point)
>     return points
>
> for dx in xrange(-mask_size2, mask_size2 + 1):
>         for dy in xrange(-mask_size2, mask_size2 + 1):

What is the meaning and value of mask_size2 ?  Is it a negative int?

>             ix, iy = x + dx, y + dy
>             addpoints(data, points, ix , iy )
>
>

BTW, this function's initial comment is incorrect.  It doesn't make a
list, it appends to one passed in.  And there's no point in returning
that list, since it has already been modified.  By good convention, a
simple function either returns a result or modifies its parameter, it
shouldn't do both.  Obviously there are exceptions for complex
functions, but even then, for a single collection, it should either be
modified in place, or created and returned, not both.

-- 

DaveA

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


Thread

Re: error Dave Angel <d@davea.name> - 2012-11-06 08:05 -0500
  Re: error woooee <woooee@gmail.com> - 2012-11-06 11:59 -0800
    Re: error Dave Angel <d@davea.name> - 2012-11-08 11:33 -0500
    Re: error Jerry Hill <malaclypse2@gmail.com> - 2012-11-08 11:41 -0500
    Re: error inshu chauhan <insideshoes@gmail.com> - 2012-11-09 11:53 +0100
    Re: error inshu chauhan <insideshoes@gmail.com> - 2012-11-09 12:47 +0100
    Re: error inshu chauhan <insideshoes@gmail.com> - 2012-11-09 14:59 +0100
    Re: error inshu chauhan <insideshoes@gmail.com> - 2012-11-09 15:08 +0100
    Re: error Dave Angel <d@davea.name> - 2012-11-12 10:04 -0500

csiph-web