Karsten Wutzke wrote: > I have an object which has a list of other complex objects. How do I > best achieve a complex "contains" comparison based on the object's > class? In Java terms, I'm looking for an equivalent to equals(Object) > in Python. Does a similar thing exist? Directions appreciated.
I can't infer from your question whether you already know about __contains__(). So there: >>> class Cornucopia: ... def __contains__(self, other): ... return True ... >>> c = Cornucopia() >>> 42 in c True >>> "cherry pie" in c True >>> c in c True -- http://mail.python.org/mailman/listinfo/python-list