def firstval(*values, default=None, sentinel=None):
    """
    Get the first value in values which is not sentinel

    For delayed execution (similar to a if b else c) a value can be a
    callable which should return the value in question

    Example:

    default = firstval(a, config['a'], lambda: lengthycomputation())
    """
    for value in values:
        if callable(value):
            value2 = value()
            if value2 is not sentinel:
                return value2
        elif value is not sentinel:
            return value
    return default
