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


      

Reply via email to