From c919910cca32a2ab7ec1bf28747e4f6214acad77 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Thu, 2 Jul 2009 20:01:28 +0000 Subject: [PATCH] Tweaks to replace for loops with built-in functions and list comprehensions svn: r12756 --- src/gen/plug/menu/_enumeratedlist.py | 7 +------ src/gen/plug/menu/_filter.py | 8 ++------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/gen/plug/menu/_enumeratedlist.py b/src/gen/plug/menu/_enumeratedlist.py index 96ae08173..9c9da2093 100644 --- a/src/gen/plug/menu/_enumeratedlist.py +++ b/src/gen/plug/menu/_enumeratedlist.py @@ -110,12 +110,7 @@ class EnumeratedListOption(Option): @type value: The type will depend on the type of option. @return: nothing """ - found = False - for (opt_value, opt_description) in self.__items: - if value == opt_value: - found = True - - if found: + if any(value == v for v, d in self.__items): Option.set_value(self, value) else: print "Value %s not found for option %s" % ( str(value), diff --git a/src/gen/plug/menu/_filter.py b/src/gen/plug/menu/_filter.py index d6b906512..677971fa4 100644 --- a/src/gen/plug/menu/_filter.py +++ b/src/gen/plug/menu/_filter.py @@ -62,14 +62,10 @@ class FilterOption(EnumeratedListOption): @type filter_list: array @return: nothing """ - items = [] curval = self.get_value() + items = [(value, filt.get_name()) + for value, filt in enumerate(filter_list)] - value = 0 - for filt in filter_list: - items.append((value, filt.get_name())) - value += 1 - self.__filters = filter_list self.clear() self.set_items( items )