J
jbperez808
I find myself having to do the following:
x = (some complex expression)
y = x if x else "blah"
and I was wondering if there is any built-in idiom that
can remove the need to put (some complex expression)
in the temporary variable x.
e.g. something like the below:
y= foobar ((some complex expression), "blah")
I realized foobar() can be easily coded as:
def foobar(a,b):
if a: return a
else: return b
But I was wondering if there was a built-in function or syntax
that already does this.
x = (some complex expression)
y = x if x else "blah"
and I was wondering if there is any built-in idiom that
can remove the need to put (some complex expression)
in the temporary variable x.
e.g. something like the below:
y= foobar ((some complex expression), "blah")
I realized foobar() can be easily coded as:
def foobar(a,b):
if a: return a
else: return b
But I was wondering if there was a built-in function or syntax
that already does this.