firstval¶
- emlib.misc.firstval(*values, sentinel=None)[source]¶
Get the first value in values which is not sentinel.
At least one of the values should differ from sentinel, otherwise an exception is raised. To allow short-cirtcuit lazy evaluation, a callable can be given as value, in which case the function will only be evaluated if the previous values where sentinel
Example
config = {'a': 10, 'b': 20} def func(a=None, b=None): a = firstval(a, lambda: computation(), config['a'])