From 1c0172be5ce88cf468b940008948c49eedc3eddc Mon Sep 17 00:00:00 2001 From: Maxim Kulkin Date: Sun, 15 Sep 2013 17:45:25 +0400 Subject: [PATCH] Added index() helper function --- ostack_validator/common.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ostack_validator/common.py b/ostack_validator/common.py index d0d1c37..0d83350 100644 --- a/ostack_validator/common.py +++ b/ostack_validator/common.py @@ -3,6 +3,14 @@ def find(l, predicate): results = [x for x in l if predicate(x)] return results[0] if len(results) > 0 else None +def index(l, predicate): + i = 0 + while i