[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] BUG: The behavior of the Group.has method vs. its documentation
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] BUG: The behavior of the Group.has method vs. its documentation
- From: René Dudfield <renesd@xxxxxxxxx>
- Date: Mon, 1 Feb 2010 19:42:38 +0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 01 Feb 2010 06:42:48 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=N2gqLJ8vFTqsSUTqQ33vTpASjjamw7KiaqXZxFpK/lk=; b=aw0spT8DbRuxEQELpUQUxsvb61utVNpLfpeESFx+48euEZTYWS1AiI4YXLcP36GU1Q JU9vtkZJTynBnGiMV+Nf+AnPkajEwAtnFGzCQsg3KdSuRqWweigXrFyI/we1ZZovNUnI 6pKGIH2guW1toC3pOxTB6WkzJDEMxK7gIaHo0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=ozFaPMrd7qGOF179ujw5ijQhw8unhUJrn1Jf03xVYT99iOxuAPwjhe0NupfkV13GT9 ySe2RVyqKm3gsczGQivvYmtdMafLebG0Qh8AzuB8bmobPin2bdnrrZ6MRbxJdkSjbsCA EzGN90KXY4/IBSuRK5y2Bm7OTio9VcBXX05AI=
- In-reply-to: <653095.41813.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- References: <653095.41813.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
On Mon, Feb 1, 2010 at 7:15 PM, Jason M. Marshall <jmm0@xxxxxxxxx> wrote:
> In the pygame.sprite module, I think that the Group.has method does not behave according to its documentation. The online documentation states that Group.has will return True if the Group contains ALL of the given sprites. However, in a certain case, Group.has will return True if the Group contains ANY of the given sprites. In the following interactive code example, grp1.has(spr1, spr2) should return False, but it returns True:
>
>>>> import pygame
>>>> spr1 = pygame.sprite.Sprite()
>>>> spr2 = pygame.sprite.Sprite()
>>>> grp1 = pygame.sprite.Group(spr1)
>>>> grp1.has(spr1)
> True
>>>> grp1.has(spr2)
> False
>>>> grp1.has(spr2, spr1)
> False
>>>> grp1.has(spr1, spr2)
> True
>>>>
>
> I'm already in the process of tidying up the pygame.sprite module so that it'll make fewer function calls, make fewer hash table look-ups and conform to PEP 8 better. So far, I haven't made any changes that could break any existing code, but if I change the AbstractGroup.has code to match the documentation, then someone's game could break if it depends on the incorrect behavior of Group.has.
>
> Would it be OK with all of you if I change Group.has to match the documentation?
>
> Thanks,
> Jason
>
Best to fix the docs, and add another method.
Also, there are not full unittests for the sprite module, so it would
be good to get some unittests completed first... so that it would be
sure to catch any errors with your refactoring.
cu,