[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] BUG? rect __eq__



I would have thought so too... but they don't seem to be as equal as they could be:

[phil@localhost ~]$ python
Python 2.4.1 (#2, Aug 25 2005, 18:20:57)
[GCC 4.0.1 (4.0.1-2mdk for Mandriva Linux release 2006.0)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> (0,0,10,10) != [0,0,10,10]
True
>>>    

Joe Wreschnig <piman@xxxxxxxxxxxxxx> wrote:
On Tue, 2006-06-06 at 22:12 +1000, Rene Dudfield wrote:
> Hi,
>
> thanks for the notes.
>
>
> Yes I agree the current behaviour is more useful, and probably more expected.
>
> Note that all of these are true:
> Rect(0,0,10,10) == [0,0,10,10]
> [0,0,10,10] == [0,0,10,10]
> Rect(0,0,10,10) == (0,0,10,10)
>
> However:
> (0,0,10,10) != [0,0,10,10]

This would be news to me. Tuples and lists with the same elements are
equal in Python.

id(a) == id(b) is the wrong way to write it. Use "a is b".
--
Joe Wreschnig

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com