import six


def is_iterable(x):
    """Determine whether an element is iterable.

    This function determines whether an element is iterable by checking
    for the ``__iter__`` attribute. Since Python 3.x adds the ``__iter__``
    attribute to strings, we also have to make sure the input is not a
    string or unicode type.

    Parameters
    ----------
    x : object
        The object or primitive to test whether
        or not is an iterable.
    """
    if isinstance(x, six.string_types):
        return False
    return hasattr(x, '__iter__')