lib/util/dict.py
def is_collection(value):
    '''
    Returns true if `value` is a collection-like object.

    Examples of these are lists and dictionaries.
    Examples of non-collection objects are numbers and strings.
    '''
    if isinstance(value, (tuple, list, dict)):
        # collections for sure
        return True

    collection_attrs = (
        '__getitem__', '__setitem__', '__delitem__',
        # this is not necessarily true, but required for the implementation
        # of `merge_dicts` below:
        '__iter__', '__contains__',
    )
    for collection_attr in collection_attrs:
        if not hasattr(value, collection_attr):
            # nope - collections must include all of them
            return False

    # not sure, say yes since it supports all operations needed to merge
    return True

    Returns true if `value` is a collection-like object.

    Examples of these are lists and dictionaries.
    Examples of non-collection objects are numbers and strings.
    
Returns true if `value` is a collection-like object.
Examples of these are lists and dictionaries.
Examples of non-collection objects are numbers and strings.
Returns true if ` value ` is a collection - like object . Examples of these are lists and dictionaries . Examples of non - collection objects are numbers and strings .
def is_collection(value):
    if isinstance(value, (tuple, list, dict)):
        return True
    collection_attrs = (
        '__getitem__', '__setitem__', '__delitem__',
        '__iter__', '__contains__',
    )
    for collection_attr in collection_attrs:
        if not hasattr(value, collection_attr):
            return False
    return True
def is_collection ( value ) : if isinstance ( value , ( tuple , list , dict ) ) : return True collection_attrs = ( '__getitem__' , '__setitem__' , '__delitem__' , '__iter__' , '__contains__' , ) for collection_attr in collection_attrs : if not hasattr ( value , collection_attr ) : return False return True
Returns true if `value` is a collection-like object.
Returns true if ` value ` is a collection - like object .
'''
    Returns true if `value` is a collection-like object.

    Examples of these are lists and dictionaries.
    Examples of non-collection objects are numbers and strings.
    ''' # collections for sure # this is not necessarily true, but required for the implementation # of `merge_dicts` below: # nope - collections must include all of them # not sure, say yes since it supports all operations needed to merge
value