def getArg(name, kwarg):
    """Return a single (name, value) pair from a keyword argument
    dictionary, raising a TypeError if there is not exactly one
    keyword argument."""

    if len(kwarg) != 1:
        raise TypeError("%s takes exactly 1 keyword argument" % name)
    return kwarg.iteritems().next()