def _get_arg(argname, args, kwargs):
    """Get an argument, either from kwargs or from the first entry in args.
    Raises a TypeError if argname not in kwargs and len(args) == 0.
    Mutates kwargs in place if the value is found in kwargs.

    Args:
        argname (str): argument name to get
        args (tuple): args to look in
        kwargs (dict): kwargs to look in
    Returns:
        argument, remaining args
    """
    try:
        return kwargs.pop(argname), args
    except KeyError:
        pass
    try:
        return args[0], args[1:]
    except IndexError:
        raise TypeError("No value passed for %s" % argname)