if or elif either true then do something

You could also omit the either_true flag completely if doSomething3 is a single line of code (e.g. a function call):

if x:
  ..do something 1
  ..do something 3
elif y:
  ..do something 2
  ..do something 3

It maintains the nice property of evaluating x and y at most once (and y won’t be evaluated if x is true).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)