It is often preferred that you use __eq__, __ne__, __lt__, etc.
instead of __cmp__. If you are only defined equality, define __eq__
and (as usually applicable) __ne__.
On Sun, Nov 9, 2008 at 4:49 PM, David Symonds <[EMAIL PROTECTED]> wrote:
>
> On Sun, Nov 9, 2008 at 3:36 PM, jmay <[EMAIL PROTECTED]> wrote:
>
>> It appears that entities cannot be compared directly:
>>
>> e1 = MyEntity.get('longkeystringhere')
>> e2 = MyEntity.get('samekeystringhere')
>>
>> "e1 == e2" will return False even if identical keys are provided.
>>
>> But 'e1.key() == e2.key()' returns True.
>
> That makes perfect sense because you might have changed e2's
> properties (and even saved e2). If you want to make your entities
> comparable, you should define a __cmp__ function on the entity class
> yourself. Also, if you're going to use them as dictionary keys, define
> a __hash__ function as well.
>
>
> Dave.
>
> >
>
--
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---