Ternary expression for a getOrElse semantic

Scala has a convenient method to get a default value if one parameter is missing. Python doesn't provide this feature as a native function. It can be implemented with a ternary expression, though.

Let's take the following situation. Our code needs to use the list from the input parameter if it's defined, or create a new empty one otherwise. You can write it with an if-else statement but if you do care about the conciseness, you can inline it:

def add_numbers(new_number, numbers = None):
  numbers_to_add = numbers if numbers else []
  numbers_to_add.append(new_number)
  return numbers_to_add