<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def get_attr(item, name, default=None):
    ''' similar to getattr and get but will test for class or dict '''
    try:
        val = item[name]
    except (KeyError, TypeError):
        try:
            val = getattr(item, name)
        except AttributeError:
            val = default
    return val