def getmembers(object, predicate=None):
 results = []
 for key in dir(object):
  value = getattr(object, key)
  if ((not predicate) or predicate(value)):
   results.append((key, value))
 results.sort()
 return results

def getmembers ( object , predicate = None ) : results = [ ] for key in dir ( object ) : value = getattr ( object , key ) if ( ( not predicate ) or predicate ( value ) ) : results . append ( ( key , value ) ) results . sort ( ) return results
return all members of an object as pairs sorted by name .