def transform_len(val, default=None):
    """
    Calculate length
        <dotted>|len                len(val) or raises
        <dotted>|len:<default>      len(val) or <default>
    """
    try:
        return len(val)
    except TypeError:
        if default is not None:
            return default
        raise
    return val