def axis_lens(seq, axis=0):
    """Return length of `axis` of all arrays in `seq`.

    If an entry in `seq` is None instead of an array, return 0. All arrays must
    have at least axis+1 dimensions, of course (i.e. axis=1 -> all arrays at
    least 2d).

    Examples
    --------
    >>> axis_lens([arange(100), np.array([1,2,3]), None, rand(5,3)])
    [100, 3, 0, 5]
    """
    ret = []
    for xx in seq:
        try:
            # handle None
            ret.append(xx.shape[axis])
        except AttributeError:
            ret.append(0)
    return ret