2 Providing iterator functions that are not in all version of Python we support.
3 Where possible, we try to use the system-native version and only fall back to
4 these implementations if necessary.
11 # Fallback for Python 2.5
12 def product(*args
, **kwds
):
14 Taken from http://docs.python.org/library/itertools.html#itertools.product
16 # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
17 # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
18 pools
= map(tuple, args
) * kwds
.get('repeat', 1)
21 result
= [x
+[y
] for x
in result
for y
in pool
]
25 if hasattr(itertools
, 'product'):
26 product
= itertools
.product
29 "A implementation independent way of checking for iterables"
38 warnings
.warn("django.utils.itercompat.all is deprecated; use the native version instead",
39 PendingDeprecationWarning
)
40 return __builtin__
.all(iterable
)
43 warnings
.warn("django.utils.itercompat.any is deprecated; use the native version instead",
44 PendingDeprecationWarning
)
45 return __builtin__
.any(iterable
)