mirror of https://github.com/mahmoud/boltons.git
iterutils Python 3 compat (izip/xrange)
This commit is contained in:
parent
ea0b475999
commit
69ef72d51c
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue