def indexMatching(seq, condition):
    for i, x in enumerate(seq):
        if condition(x):
            return i
return -1


class Z(object):

    def __init__(self, name):
        self.name = name


class X(object):

    def __init__(self, zs):
        self.mylist = list(zs)

def indexByName(self, name):
    return indexMatching(self.mylist, lambda x: x.name == name)
x = X([Z('Fred'), Z('Barney'), Z('Wilma'), Z('Betty')])
print(x.indexByName('Wilma'))
Операции списка Python, лямбда-выражение