def unpack_di_block(di_block):
    """
    This function unpacks a nested list of [dec,inc,mag_moment] into a list of
    declination values, a list of inclination values and a list of magnetic
    moment values. Mag_moment values are optional, while dec and inc values are
    required.

    Parameters
    -----------
    di_block : nested list of declination, inclination lists

    Returns
    -----------
    dec : list of declinations
    inc : list of inclinations
    mag_moment : list of magnetic moment (if present in di_block)

    Example
    -----------
    The di_block nested lists of lists can be unpacked using the function

    >>> directions = [[180.3, 12.1, 1.0], [179.2, 13.7, 1.0], [177.2, 11.9, 1.0]]
    >>> ipmag.unpack_di_block(directions)
    ([180.3, 179.2, 177.2], [12.1, 13.7, 11.9], [1.0, 1.0, 1.0])

    These unpacked values can be assigned to variables:

    >>> dec, inc, moment = ipmag.unpack_di_block(directions)
    """
    dec_list = []
    inc_list = []
    moment_list = []

    for n in range(0, len(di_block)):
        dec = di_block[n][0]
        inc = di_block[n][1]
        dec_list.append(dec)
        inc_list.append(inc)
        if len(di_block[n]) > 2:
            moment = di_block[n][2]
            moment_list.append(moment)

    return dec_list, inc_list, moment_list