def fields_of(obj, primitives_only=False, primitives_and_composites_only=False, allow_caps=False, ignore=set()):
 r = {}
 for k in dir(obj):
  if k.startswith('_'):
   continue
  if (k in ignore):
   continue
  v = getattr(obj, k)
  if hasattr(v, '__call__'):
   continue
  if ((not allow_caps) and (k.upper() == k)):
   continue
  if primitives_only:
   if (not isinstance(v, _scalar_types)):
    continue
  elif primitives_and_composites_only:
   if (not isinstance(v, (int, long, basestring, float, bool, set, dict, list))):
    continue
  r[k] = v
 return r

def fields_of ( obj , primitives_only = False , primitives_and_composites_only = False , allow_caps = False , ignore = set ( ) ) : r = { } for k in dir ( obj ) : if k . startswith ( '_' ) : continue if ( k in ignore ) : continue v = getattr ( obj , k ) if hasattr ( v , '__call__' ) : continue if ( ( not allow_caps ) and ( k . upper ( ) == k ) ) : continue if primitives_only : if ( not isinstance ( v , _scalar_types ) ) : continue elif primitives_and_composites_only : if ( not isinstance ( v , ( int , long , basestring , float , bool , set , dict , list ) ) ) : continue r [ k ] = v return r
returns key/value pairs of things that seem like public fields of an object .