[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 particular case where the if-expression is also the conditional or the basic of the conditional expression is

y = <some complex expression>
if not y: y = "blah"

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to