#NEWLINE# def cons( collection , value ) : #NEWLINE# #INDENT# 'Extends a collection with a value.' #NEWLINE# if isinstance ( value , collections . Mapping ) : #NEWLINE# #INDENT# if ( collection is None ) : #NEWLINE# #INDENT# collection = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# collection . update ( ** value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( value , six . string_types ) : #NEWLINE# #INDENT# if ( collection is None ) : #NEWLINE# #INDENT# collection = [ ] #NEWLINE# #UNINDENT# collection . append ( value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( value , collections . Iterable ) : #NEWLINE# #INDENT# if ( collection is None ) : #NEWLINE# #INDENT# collection = [ ] #NEWLINE# #UNINDENT# collection . extend ( value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( collection is None ) : #NEWLINE# #INDENT# collection = [ ] #NEWLINE# #UNINDENT# collection . append ( value ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return collection