def to_marshallable_type(obj):
 if (obj is None):
  return None
 if hasattr(obj, '__marshallable__'):
  return obj.__marshallable__()
 if hasattr(obj, '__getitem__'):
  return obj
 return dict(obj.__dict__)

def to_marshallable_type ( obj ) : if ( obj is None ) : return None if hasattr ( obj , '__marshallable__' ) : return obj . __marshallable__ ( ) if hasattr ( obj , '__getitem__' ) : return obj return dict ( obj . __dict__ )
helper for converting an object to a dictionary only if it is not dictionary already or an indexable object nor a simple type .