On Feb 11, 2:24 pm, "LL.Snark" <ll.sn...@gmail.com> wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x<t.first}
More Javalicious than Pythonic, but this works: class ComparisonPredicate: def __init__(self, func): self.func = func def __eq__(self, other): return self.func(other) t = [6, 7, 8, 6, 7, 9, 8, 4, 3, 6, 7] print(t.index(ComparisonPredicate(lambda x: x < t[0]))) -- http://mail.python.org/mailman/listinfo/python-list