def is_iterable(obj):
    """
    Returns True if 'obj' is iterable and False otherwise.

    We check for __iter__ and for __getitem__ here because an iterable type
    must, by definition, define one of these attributes but is not required or
    guarenteed to define both of them. For more information on iterable types
    see:

        http://docs.python.org/2/glossary.html#term-iterable
        http://docs.python.org/2/library/functions.html#iter
    """
    return hasattr(obj, '__iter__') or hasattr(obj, '__getitem__')