> Any other ideas? How about this:
def random_pick(list, property): L = len(list) pos = start = random.randrange(L) while 1: x = list[pos] if property(x): return x pos = (pos + 1) % L if pos == start: raise ValueError, "no such item" Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list