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
similar to getattr and get but will test for class or dict