def rec_max(obj):
    """ Calculate the maximum in a list object obj.
    Return obj if it's an int, or the maximum int in obj,
    a possibly nested list of numbers.

    Assume: obj is an int or non-empty list with finite nesting depth,
    and obj doesn't contain any empty lists

    @param int|list[int|list[...]] obj: possibly nested list of int
    @rtype: int

    >>> rec_max([17, 21, 0])
    21
    >>> rec_max([17, [21, 24], 0])
    24
    >>> rec_max(31)
    31
    """
    if not isinstance(obj, list):
        # obj is not a list
        return obj
    elif obj == []:
        raise Exception("List should not be empty or contain empty sublists")
    else:
        # obj is a list
        return max([rec_max(elem) for elem in obj])