Return args as a list.

    If already a list - return as is.

    >>> listify([1, 2, 3])
    [1, 2, 3]

    If a set - return as a list.

    >>> listify(set([1, 2, 3]))
    [1, 2, 3]

    If a tuple - return as a list.

    >>> listify(tuple([1, 2, 3]))
    [1, 2, 3]

    If a generator (also range / xrange) - return as a list.

    >>> listify(x + 1 for x in range(3))
    [1, 2, 3]
    >>> from past.builtins import xrange
    >>> from builtins import range
    >>> listify(xrange(1, 4))
    [1, 2, 3]
    >>> listify(range(1, 4))
    [1, 2, 3]

    If a single instance of something that isn't any of the above - put as a
    single element of the returned list.

    >>> listify(1)
    [1]

    If "empty" (None or False or '' or anything else that evaluates to False),
    return an empty list ([]).

    >>> listify(None)
    []
    >>> listify(False)
    []
    >>> listify('')
    []
    >>> listify(0)
    []
    >>> listify([])
    []

def listify(args):
    """Return args as a list.

    If already a list - return as is.

    >>> listify([1, 2, 3])
    [1, 2, 3]

    If a set - return as a list.

    >>> listify(set([1, 2, 3]))
    [1, 2, 3]

    If a tuple - return as a list.

    >>> listify(tuple([1, 2, 3]))
    [1, 2, 3]

    If a generator (also range / xrange) - return as a list.

    >>> listify(x + 1 for x in range(3))
    [1, 2, 3]
    >>> from past.builtins import xrange
    >>> from builtins import range
    >>> listify(xrange(1, 4))
    [1, 2, 3]
    >>> listify(range(1, 4))
    [1, 2, 3]

    If a single instance of something that isn't any of the above - put as a
    single element of the returned list.

    >>> listify(1)
    [1]

    If "empty" (None or False or '' or anything else that evaluates to False),
    return an empty list ([]).

    >>> listify(None)
    []
    >>> listify(False)
    []
    >>> listify('')
    []
    >>> listify(0)
    []
    >>> listify([])
    []
    """
    if args:
        if isinstance(args, list):
            return args
        elif isinstance(args, (set, tuple, GeneratorType,
                               range, past.builtins.xrange)):
            return list(args)
        return [args]
    return []