iterutils Python 3 compat (izip/xrange)

This commit is contained in:
Mahmoud Hashemi 2015-04-10 00:08:24 -07:00
parent ea0b475999
commit 69ef72d51c
1 changed files with 9 additions and 3 deletions

View File

@ -9,10 +9,16 @@ returns an iterator (denoted by the ``*_iter`` naming pattern), and a
shorter-named convenience form that returns a list. Some of the
following are based on examples in itertools docs.
"""
import itertools
import itertools
from compat import basestring # TODO
try:
from itertools import izip
except ImportError:
# Python 3
izip, xrange = zip, range
def is_iterable(obj):
"""Similar in nature to :func:`callable`, ``is_iterable`` returns
@ -235,8 +241,8 @@ def windowed_iter(src, size):
for _ in xrange(i):
next(t)
except StopIteration:
return itertools.izip([])
return itertools.izip(*tees)
return izip([])
return izip(*tees)
def bucketize(src, key=None):