[Tutor] 2d list index inverting?

Alex Hall mehgcap at gmail.com
Wed May 26 04:59:46 CEST 2010


On 5/25/10, Hugo Arts <hugo.yoshi at gmail.com> wrote:
> On Wed, May 26, 2010 at 3:47 AM, Alex Hall <mehgcap at gmail.com> wrote:
>>
>> I thought so, but I was hoping you would not say that as this means a
>> logic bug deep in my code, and those are the hardest to track down...
>
> Unfortunately, yes. Bug hunting is part art, part science.
You can say that again. My major (just one year left!) is computer
science, focusing in programming (though Python is something I am
pursuing on my own), so I have done a lot of finding seemingly
impossible bugs. It is never fun, though, until that wonderful point
when you squash the offending insect!
>
>>> The real problem is something else entirely. Somewhere in your code,
>>> you are using an index that is greater than the size of the list.
>>
>> Yes, and it looks like my coordinates are bing reversed somewhere, but
>> I cannot find anywhere where that is happening in the code.
>
> This is a good thing. You already have some idea of what is happening.
> Confirm your suspicions, then work from there.
>
>>> Perhaps you're not consistent, somewhere. Mixing up your row/column
>>> order. Perhaps something else is amiss. No way to tell from the
>>> snippet.
>> So, a lot of print() statements then...
>
> It's a good start. I suggest you begin at the place where the error
> occurs, then work your way back slowly. verify at each point that your
> data is mixed up, until you find what introduced the mixup.
Yes. I have found that, somewhere, my rows are being swapped for
columns, and vice versa. My grid on the screen is 10 columns of 14
rows, but the computer sees 14 columns of 10 rows. However, I am
currently at a loss as to just where this switch is taking place.
Still, it looks like finding one line will fix it, not every reference
to coordinates.
>
> There are other some other useful tools. The python debugger might be
> of some help. http://docs.python.org/library/pdb.html
> It's especially useful to gain more insight in what precisely a piece
> of code is doing. There is a learning curve to it, but once you know
> how to use it it will pay back many times over.
I am blind, using Jaws for Windows to access my computer
(http://www.freedomscientific.com). Is this debugger a cmd line tool,
or is it / is it part of an IDE? Basically I am hoping it is not its
own interface, as these are often not too compatible with screen
readers. I will definitely read through the page, though, and that
should help to answer the above question. I just figured I would ask
in case you had any knowledge of the debugger's accessibility.
>
> I think you'll have this bug resolved soon enough by yourself, but
> should you get the urge to bang your head against a wall repeatedly,
> come back here and we'll have a closer look at it. Good luck and happy
> hunting,
>
> Hugo
Thanks! Hopefully I will not need to have anyone on here go through
the code, but sometimes the best thing is a fresh pair of eyes. The
problem is that none of my friends know a thing about Python, so I
guess that is where this list comes in, should it prove necessary.
Thanks for the offer!
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap


More information about the Tutor mailing list