Given a class, say
class Complex:
    def __init__(self, realpart, imagpart):
        self.r = realpart
        self.i = imagpart
I would like to find the position in a list of an instance of this class. For instance, given
list = [1, 2, 3, Complex(1, 1)]
how can I find the position of Complex(1, 1)?
I tried list.index(Complex(1, 1)), but the object created from the second call to Complex is not the same as the first, so this results in a ValueError exception being raised.
How could I do this?
More generally, how could I find the position in a list of any instances of Complex (e.g. for list = [1, Complex(1, 1), 2, Complex(2, 2)] to return 1 and 3)?
