If I have a function that returns some value and I only want to assign that value if its in an allowed list otherwise use a default. Assume I can't modify the function.
ie this works, but its calling the function twice.
def some_func():
return 'foo'
allowed_list = ['foo', 'bar']
value = some_func() if some_func() in allowed_list else 'default'
is there a pythonic way to set the value in a single line without calling the function twice?