def is_iterator(x):
    """An implementation independent way of checking for iterators

    Python 2.6 has a different implementation of collections.Iterator which
    accepts anything with a `next` method. 2.7+ requires and `__iter__` method
    as well.
    """
    if sys.version_info >= (2, 7):
        return isinstance(x, collections.Iterator)
    return isinstance(x, collections.Iterator) and hasattr(x, '__iter__')
dataset/ETHPy150Open daoluan/decode-Django/Django-1.5.1/django/utils/itercompat.py/is_iterator/original