Max Moroz wrote:
> Currently, __eq__() method is not defined in class operator.itemgetter,> hence non-identical itemgetter objects compare as non-equal.> > I wanted to propose defining __eq__() method that would return the result> of comparison for equality of the list of arguments submitted at> initialization. This would make operator.itemgetter('name') compare as> equal to operator.itemgetter('name').
In general, I think that having equality tests fall back on identity test is
so rarely what you actually want that sometimes I wonder why we bother.
In this case I was going to say just write your own subclass, but:
py> from operator import itemgetter
py> class MyItemgetter(itemgetter):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: type 'operator.itemgetter' is not an acceptable base type
--
Steven
_______________________________________________
Python-ideas mailing list
Pyth...@python.org
http://mail.python.org/mailman/listinfo/python-ideas