def add_tags(iterable, *taglist):
    """
    Add tags to each item in ``iterable``. Each tag is added to the ``@tags``
    array, which will be created if required.

    >>> data_in = [{'@message': 'one message'}, {'@message': 'another message'}]
    >>> data_out = add_tags(data_in, 'foo', 'bar')
    >>> [x for x in data_out]
    [{'@message': 'one message', '@tags': ['foo', 'bar']},
     {'@message': 'another message', '@tags': ['foo', 'bar']}]
    """
    k = '@tags'
    for item in iterable:
        try:
            item[k].extend(taglist)
        except (AttributeError, KeyError):
            item[k] = []
            item[k].extend(taglist)
        yield item
