def update_dict(obj, dict, attributes):
for attribute in attributes:<EOL><INDENT>if hasattr(obj, attribute) and getattr(obj, attribute) is not None:<EOL><INDENT>dict[attribute] = getattr(obj, attribute)<EOL><DEDENT><DEDENT>
Update dict with fields from obj.attributes.

    :param obj: the object updated into dict
    :param dict: the result dictionary
    :param attributes: a list of attributes belonging to obj