def _pipe(obj, func, *args, **kwargs):
if isinstance(func, tuple):<EOL><INDENT>func, target = func<EOL>if target in kwargs:<EOL><INDENT>msg = '<STR_LIT>' % target<EOL>raise ValueError(msg)<EOL><DEDENT>kwargs[target] = obj<EOL>return func(*args, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>return func(obj, *args, **kwargs)<EOL><DEDENT>
Apply a function ``func`` to object ``obj`` either by passing obj as the
first argument to the function or, in the case that the func is a tuple,
interpret the first element of the tuple as a function and pass the obj to
that function as a keyword argument whose key is the value of the second
element of the tuple.

Parameters
----------
func : callable or tuple of (callable, string)
    Function to apply to this object or, alternatively, a
    ``(callable, data_keyword)`` tuple where ``data_keyword`` is a
    string indicating the keyword of `callable`` that expects the
    object.
args : iterable, optional
    positional arguments passed into ``func``.
kwargs : dict, optional
    a dictionary of keyword arguments passed into ``func``.

Returns
-------
object : the return type of ``func``.