Thanks, folks.
Short-circuit boolean was the syntax I had in mind which
momentarily escaped me, but the "if not x: x='blah'" idiom
was instructive as well.
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 12 Oct 2008 05:30:33 +, Steven D'Aprano wrote:
> Use short-circuit Booleans:
>
> y = x or "blah"
Except of course you don't use x, you use the complex expression.
y = (some complex expression) or "blah"
Sorry for the itchy posting finger.
--
Steven
--
http://mail.python.org/m
On Sat, 11 Oct 2008 22:01:46 -0700, jbperez808 wrote:
> 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 var
On Oct 12, 12:01 am, [EMAIL PROTECTED] wrote:
> 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.
[EMAIL PROTECTED] wrote:
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.
A common idiom for this particu
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 e