def cast_var(item, klass, arg=None):
    """Attempt to cast `item` to an instance of `klass`.

    Args:
        item: The object to cast.
        klass: The class to cast to.
        arg: The kwarg name to use for the `klass` ``__init__()`` parameter. If
            ``None``, a positional argument will be used.

    """
    if not arg:
        return klass(item)

    kwarg = {arg: item}     # kwarg dict
    return klass(**kwarg)