From 0d2d6daef850ac6bcc7fafccd230e52d2a862c2c Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 3 Jun 2012 17:45:10 +0200 Subject: updates for database + api --- module/utils/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'module/utils/__init__.py') 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""" -- cgit v1.2.3