summaryrefslogtreecommitdiffstats
path: root/module/utils
diff options
context:
space:
mode:
Diffstat (limited to 'module/utils')
-rw-r--r--module/utils/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/module/utils/__init__.py b/module/utils/__init__.py
index 37e65c738..28d734bb5 100644
--- a/module/utils/__init__.py
+++ b/module/utils/__init__.py
@@ -212,6 +212,15 @@ def from_string(value, typ=None):
else:
return value
+def get_index(l, value):
+ """ .index method that also works on tuple and python 2.5 """
+ for pos, t in enumerate(l):
+ if t == value:
+ return pos
+
+ # Matches behavior of list.index
+ raise ValueError("list.index(x): x not in list")
+
def html_unescape(text):
"""Removes HTML or XML character references and entities from a text string"""