<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def resolve_attr(obj, name):
 """A custom attrgetter that operates both on dictionaries and objects"""

    # TODO: setup some hinting, so we can go directly to the correct
    # Maybe it's a dict ? Let's try dict lookup, it's the fastest
    try:
        return obj[name]
    except TypeError:
        pass
    except KeyError:
        raise exceptions.MissingField('Dict {0} has no attribute or key "{1}"'.format(obj, name))

    # Okay, it's not a dict, what if we try to access the value as for a regular object attribute?
    try:
        # Slight hack for better speed, since accessing dict is fast
        return obj.__dict__[name]
    except (KeyError, AttributeError):
        pass

    try:
        # Lookup using regular attribute
        return getattr(obj, name)
    except AttributeError:
        pass

    # Last possible choice, it's an iterable
    if isinstance(obj, collections.Iterable):
        return IterableAttr(obj, name)

    raise exceptions.MissingField('Object {0} has no attribute or key "{1}"'.format(obj, name))