def get_field(fields, field):
    """Returns fields[field], raises AttributeError on KeyError."""
    try:
        return fields[field]
    except KeyError:
        raise AttributeError("'syrecord' object has no attribute '{0}'".
            format(field))
