Browse Source

add comparision opperators, this is a major bug fix.. previously

two empty containers would compare equal causing the removal of
the first one if a later one was really removed...  The problems
of inheriting from list.. :(

It was previously masked because I would expand everything by
default and now that I don't, more items are empty exposing the
bug...

[git-p4: depot-paths = "//depot/": change = 884]
v0.3
John-Mark Gurney 18 years ago
parent
commit
0e77d25b16
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      DIDLLite.py

+ 23
- 0
DIDLLite.py View File

@@ -59,6 +59,29 @@ class Object(object):
if kwargs.has_key('content'):
self._content = kwargs['content']

def __lt__(self, other):
return self.__cmp__(other) < 0

def __le__(self, other):
return self.__cmp__(other) <= 0

def __eq__(self, other):
return self.__cmp__(other) == 0

def __ne__(self, other):
return self.__cmp__(other) != 0

def __gt__(self, other):
return self.__cmp__(other) > 0

def __ge__(self, other):
return self.__cmp__(other) >= 0

def __cmp__(self, other):
if not isinstance(other, self.__class__):
return 1
return cmp(self.id, other.id)

def __repr__(self):
cls = self.__class__
return '<%s.%s: id: %s, parent: %s, title: %s>' % \


Loading…
Cancel
Save