import random


def randit(it, rand=None):
    """ Random object from iterable.

        Return an occurrence at random from the given iterable, using `rand` if
        given or else a new `Random` object.
    """
    return it[(rand or random.Random()).randrange(0, len(it))]