[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Subtle Memory Bug
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Subtle Memory Bug
- From: James Hofmann <jwhinfinity@xxxxxxxxx>
- Date: Wed, 12 Jul 2006 17:30:03 -0700 (PDT)
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Wed, 12 Jul 2006 20:30:14 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=RAHo8Vz0Pzehy/EcJR+YpOq2YrbRJ7PN5IJHHiyJDEj27FHd5MXx1yZNoPlAj5Z1jJ9N3NgyGGZVb2gm7hxyFHP+o3705nUy8/G9cLnK38VxeY4JE+IunoEy4VAk3iDQ8YdRrqcKshIwsfv4m0AG2R9r/2vpxXfBfXE2SMEqNhc= ;
- In-reply-to: <44B50078.50503@xepher.net>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
--- Kris Schnee <kschnee@xxxxxxxxxx> wrote:
> So, like this?
>
> foo = [<instance>, <instance>, etc.]
> n = 0
> while n < len(foo):
> foo[n].DoStuff() ## Might result in deleting
> foo[n]
> n += 1
>
> I think I've done something like that before, but I
> don't remember
> whether len(foo) gets evaluated anew each time.
I don't remember either, but in this particular
situation you can structure the loop so that it
doesn't matter. Set n to len(foo) and count downwards
to 0. Items that are deleted will be "behind" your
count now.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com