def isfirstlast(iterable):
    """
	Iterate through items of the iterable and give information about whether the
	item is the first and/or last in the iterable::

		>>> list(misc.isfirstlast("foo"))
		[(True, False, 'f'), (False, False, 'o'), (False, True, 'o')]
	"""
    lastitem = None
    first = True
    it = iter(iterable)
    try:
        item = next(it)
    except StopIteration:
        return
    while True:
        try:
            lastitem, item = item, next(it)
        except StopIteration:
            yield first, True, item
            return
        else:
            yield first, False, lastitem
            first = False
