On Tue, May 18, 2010 at 11:13:42PM +0100, Gustavo Narea wrote:
> To sum up, it would behave like a tuple or a list, except when it's compared 
> with another object: They would be equivalent if they're both unordered 
> tuples/lists, and have the same elements. There can be mutable and immutable 
> editions (UnorderedList and UnorderedTuple, respectively).

class UnorderedList(list):
    def __eq__(self, other):
        if not isinstance(other, UnorderedList):
            return False
        return sorted(self) == sorted(other)

    def __ne__(self, other):
        return not self.__eq__(other)

   Do you need more than that?

Oleg.
-- 
     Oleg Broytman            http://phd.pp.ru/            p...@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to