[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] BUG? rect __eq__
- To: pygame-users@xxxxxxxx
- Subject: [pygame] BUG? rect __eq__
- From: "Rene Dudfield" <renesd@xxxxxxxxx>
- Date: Tue, 6 Jun 2006 21:37:38 +1000
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Tue, 06 Jun 2006 07:37:50 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=CJU24mjNDCxKCWGBFoxL1/TImlSH5kEC7gVVVXJS3BMicH4FcwFz/8vAFxf2NFx925C2zAfx8/qqmqGogEXsv1A217nm8k+WkcB3OTA54MbMlwGTKaMBAUPkS6UxejAbpxX52a8ZvYc9mM806YbCKmA3PnEh7P2WshQXda28jwY=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hi,
I've been going through the doc comments and found this one about the
Rect __eq__ method.
I've added a unittest for the rect __eq__ behaviour.
Could this behaviour be improved at all?
"""WARNING: The Rect class has overridden some of the comparison
methods of an object. One problem that occurs because of this is, if
you have a list with multiple instances of a Rect WITH THE SAME
RECTANGLE VALUES and you want to remove one, the wrong instance may be
removed from the list.
This was a trouble for me when I subclassed Rect for my own object
type with extended information. I corrected it by restoring __eq__ to
it's basic definition. (comparing object identifiers)
class foo (pygame.Rect):
def __eq__(self,other):
return id(self) == id(other);
"""