[Zope-Checkins] SVN: Zope/branches/andig-compositeindex/src/Products/PluginIndexes/CompositeIndex/util.py switched to native python methods
Andreas Gabriel
cvs-admin at zope.org
Fri Aug 24 13:35:14 UTC 2012
Log message for revision 127566:
switched to native python methods
Changed:
U Zope/branches/andig-compositeindex/src/Products/PluginIndexes/CompositeIndex/util.py
-=-
Modified: Zope/branches/andig-compositeindex/src/Products/PluginIndexes/CompositeIndex/util.py
===================================================================
--- Zope/branches/andig-compositeindex/src/Products/PluginIndexes/CompositeIndex/util.py 2012-08-24 13:33:43 UTC (rev 127565)
+++ Zope/branches/andig-compositeindex/src/Products/PluginIndexes/CompositeIndex/util.py 2012-08-24 13:35:10 UTC (rev 127566)
@@ -11,14 +11,17 @@
#
##############################################################################
-from itertools import chain, combinations
+from itertools import chain
+from itertools import combinations
+from itertools import product as cartesian_product
_marker = []
-class PermuteKeywordList:
- """
+class CartesianProduct:
+ """ Cartesian product of input iterables.
returns a flat list of a sequential
permutation of keyword lists.
+
Example:
A = [[1,2,3],[4,5],[6,7]]
@@ -95,7 +98,12 @@
+# since python 2.6 CartesianProduct class is obsolete
+# itertools library provides a native function
+def product(*args, **kwds):
+ return cartesian_product(*args, **kwds)
+# adapted from http://docs.python.org/library/itertools.html#recipes
def powerset(iterable,start=0):
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(start,len(s)+1))
More information about the Zope-Checkins
mailing list