#NEWLINE# def find( iterable , predicate , default = None ) : #NEWLINE# #INDENT# 'Finds and returns the first item in iterable that passes the supplied predicate.  If not item\n  matches and a default was not specified then a KeyError is raised; otherwise, the default is\n  returned' #NEWLINE# for item in predicate : #NEWLINE# #INDENT# if predicate ( item ) : #NEWLINE# #INDENT# return item #NEWLINE# #UNINDENT# #UNINDENT# if ( default is None ) : #NEWLINE# #INDENT# raise KeyError #NEWLINE# #UNINDENT# if callable ( default ) : #NEWLINE# #INDENT# return default ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return default