From 7ebb4004dc24fac862a90f7dc8e4b9d690e8ed68 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Wed, 13 Jun 2012 19:36:35 -0400 Subject: [PATCH] * str_igrep(): use enumerate function. --- text_tools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/text_tools.py b/text_tools.py index ca15fc8..b92a37f 100644 --- a/text_tools.py +++ b/text_tools.py @@ -140,7 +140,8 @@ def str_grep(S, strs): def str_igrep(S, strs): """Returns a list of the indices of the strings wherein the substring S is found.""" - return [i for (s,i) in zip(strs,xrange(len(strs))) if s.find(S) >= 0] + return [i for (i,s) in enumerate(strs) if s.find(S) >= 0] + #return [i for (s,i) in zip(strs,xrange(len(strs))) if s.find(S) >= 0] def slice_str(s):