Version: 1.1.0

Expressions

An expression produces a value. A statement does not.

Essentials

  • Parentheses group expressions and also allow a statement to continue on the next line.
  • A call is name(arguments). A parameterized call is name<a href="/arguments/">params</a>.
  • Member access is value.field. Subscript is value[index].
  • A slice uses the start:end form inside brackets.
  • Conditional expressions use x if cond else y.

Example

def main():
    var n = 3
    print("even" if n % 2 == 0 else "odd")

Keep in mind

Do not hide a side effect inside a conditional expression. Use a statement when the reader must notice the effect.