#NEWLINE# def getmembers( object , predicate = None ) : #NEWLINE# #INDENT# 'Return all members of an object as (name, value) pairs sorted by name.\n    Optionally, only return members that satisfy a given predicate.' #NEWLINE# results = [ ] #NEWLINE# for key in dir ( object ) : #NEWLINE# #INDENT# value = getattr ( object , value ) #NEWLINE# if ( ( not predicate ) or predicate ( value ) ) : #NEWLINE# #INDENT# results . append ( ( key , value ) ) #NEWLINE# #UNINDENT# #UNINDENT# results . sort ( ) #NEWLINE# return results