def describe_attributes(obj, attrs, func=None):
 if (not func):
  func = (lambda x: x)
 pairs = []
 for attr in attrs:
  value = getattr(obj, attr, None)
  if func(value):
   pairs.append(('%s=%s' % (attr, value)))
 return ', '.join(pairs)

def describe_attributes ( obj , attrs , func = None ) : if ( not func ) : func = ( lambda x : x ) pairs = [ ] for attr in attrs : value = getattr ( obj , attr , None ) if func ( value ) : pairs . append ( ( '%s=%s' % ( attr , value ) ) ) return ', ' . join ( pairs )
helper for __repr__ functions to list attributes with truthy values only .