def dict_dir(obj):
 ns = {}
 for key in dir2(obj):
  try:
   ns[key] = getattr(obj, key)
  except AttributeError:
   pass
 return ns

def dict_dir ( obj ) : ns = { } for key in dir2 ( obj ) : try : ns [ key ] = getattr ( obj , key ) except AttributeError : pass return ns
produce a dictionary of an objects attributes .