def base_set(obj, key, value, allow_override=True):
    """Set an object's `key` to `value`. If `obj` is a ``list`` and the
    `key` is the next available index position, append to list; otherwise, pad
    the list of ``None`` and then append to the list.

    Args:
        obj (list|dict): Object to assign value to.
        key (mixed): Key or index to assign to.
        value (mixed): Value to assign.
    """
    if isinstance(obj, dict):
        if allow_override or key not in obj:
            obj[key] = value
    elif isinstance(obj, list):
        key = int(key)
        if key < len(obj):
            if allow_override:
                obj[key] = value
        else:
            if key > len(obj):
                obj[:] = (obj + [None] * key)[:key]
            obj.append(value)
    return obj
