logo       

Re: off by one error, line 55 in arraydemo.py: msg#00243

python.pygame

Subject: Re: off by one error, line 55 in arraydemo.py

Hey, by the way, thanks for spending time on the tutorial (and arraydemo.py?). I've found that the interesting slices in the demo has given me some good insights and intuitions about slicing. Hell, just knowing how to get even/odd items from an array is likely to save me a lot of trouble in the future.

Miles

From: Peter Shinners <pete-eNbnrwMA38Zg9hUCZPvPmw@xxxxxxxxxxxxxxxx>
Reply-To: pygame-users-eePT7DaMpNY@xxxxxxxxxxxxxxxx
To: pygame-users-eePT7DaMpNY@xxxxxxxxxxxxxxxx
Subject: Re: [pygame] off by one error, line 55 in arraydemo.py
Date: Wed, 28 Sep 2005 19:51:34 -0700

On Wed, 2005-09-28 at 10:47 -0700, Miles Van Pelt wrote:
> Line 55 in arraydemo.py
> flipped = imgarray[:,-1:0:-1]
>
> This should be:
> flipped = imgarray[:,-1::-1]


You're right. It looks like the Numeric slicing doesn't really need
bounds anyways when reversing. So just doing ::-1 will work fine.







<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise