def mean(seq):
    """Return the mean of all values from seq."""
    try:
        N = float(len(seq))
        return sum(seq) / N
    except TypeError:
        N = S = 0.0
        for x in seq:
            N += 1
            S += x
        return S / N
