osdir.com
mailing list archive

Subject: Re: [pygame] array search - msg#00052

List: python.pygame

Date: Prev Next Index Thread: Prev Next Index
Nicolás Sanguinetti wrote:
AFAIK, no, you can only find all indexes by iterating through the array.
cheers

In Python 2.3, you can use "enumerate".

http://www.python.org/doc/current/whatsnew/section-enumerate.html



Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: [pygame] array search

On Saturday 27 March 2004 07:33, Nicolás Sanguinetti wrote: > AFAIK, no, you can only find all indexes by iterating through the array. > cheers > > Nicolas Even if there is some syntactic sugar to make this easier ( And I think there is, check out the docs on NumArray ), it essentially still uses a for loop inside to walk through the array. It merely keeps you from having to write one yourself. :) -Daniel

Next Message by Date: click to view message preview

Re: [pygame] array search

On Mar 27, 2004, at 4:40 PM, Derek Simkowiak wrote: Nicolás Sanguinetti wrote: AFAIK, no, you can only find all indexes by iterating through the array. cheers In Python 2.3, you can use "enumerate". http://www.python.org/doc/current/whatsnew/section-enumerate.html Well "finding all indexes" is easy enough: range(len(anArray)) The problem at hand is "finding all indexes that are not 0", so you obviously do have to iterate through the whole array to find them... whether or not you explicitly use 'for' to do it. -bob smime.p7s Description: S/MIME cryptographic signature

Previous Message by Thread: click to view message preview

Re: [pygame] array search

On Saturday 27 March 2004 07:33, Nicolás Sanguinetti wrote: > AFAIK, no, you can only find all indexes by iterating through the array. > cheers > > Nicolas Even if there is some syntactic sugar to make this easier ( And I think there is, check out the docs on NumArray ), it essentially still uses a for loop inside to walk through the array. It merely keeps you from having to write one yourself. :) -Daniel

Next Message by Thread: click to view message preview

Re: [pygame] array search

On Mar 27, 2004, at 4:40 PM, Derek Simkowiak wrote: Nicolás Sanguinetti wrote: AFAIK, no, you can only find all indexes by iterating through the array. cheers In Python 2.3, you can use "enumerate". http://www.python.org/doc/current/whatsnew/section-enumerate.html Well "finding all indexes" is easy enough: range(len(anArray)) The problem at hand is "finding all indexes that are not 0", so you obviously do have to iterate through the whole array to find them... whether or not you explicitly use 'for' to do it. -bob smime.p7s Description: S/MIME cryptographic signature
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by