Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix A: Keywords

Zuri reserves thirty-one words. None of them can be used as a variable, function, class or parameter name.

KeywordWhat it doesCovered in
andlogical conjunction, short-circuitingOperators
asbinds an error in catch, or renames an importErrors, Modules
assertraises AssertError when its condition is falsyControl Flow
breakleaves the innermost loopControl Flow
catchruns a block, intercepting anything it raisesErrors
classdeclares a class, or with > an extension to oneClasses, Extensions
constdeclares a name that cannot be reassignedVariables
continueskips to the next iterationControl Flow
defdeclares a function, named or anonymousFunctions
defaultthe fall-through branch of a usingControl Flow
dobegins a do/while loopControl Flow
echoprints a value and a newlineHello, World!
elsethe alternative branch of an ifControl Flow
falsethe boolean falseData Types
foriterates over anything iterableControl Flow
ifconditional branchControl Flow
importloads a moduleModules
inseparates a for loop’s variables from its iterableControl Flow
iterthe counting loopControl Flow
nilthe absence of a valueData Types
orlogical disjunction, short-circuitingOperators
parentthe superclass constructor, or a superclass methodInheritance
raiseraises an errorErrors
returnleaves the current functionControl Flow
selfthe current instance, inside a methodClasses
staticputs a field or method on the class, not the instanceClasses
truethe boolean trueData Types
usingmulti-way branch on one subjectControl Flow
vardeclares a variableVariables
whenone branch of a usingControl Flow
whilethe conditional loopControl Flow

Names That Are Not Keywords

These are ordinary globals, not reserved words, so nothing stops you from shadowing one. Doing so is a good way to confuse the next reader:

time      sum       bytes     file      instance_of  typeof
delprop   getprop   hasprop   setprop   id           print
rand      is_bigint is_bool   is_bytes  is_callable  is_class
is_dict   is_file   is_function is_instance is_int    is_iterable
is_list   is_number is_object is_string

The built-in error classes are also globals: Error, TypeError, ValueError, NumericError, ArgumentError, NotImplementedError, RangeError, AccessError, AssertError, PropertyError, UndefinedError and ModuleNotFoundError.

Reserved by Convention

Two module-level names are provided by the runtime rather than declared by you: __file__ and __root__. See Modules.

Names beginning with $ are never produced by the lexer, which is how the compiler synthesises loop variables that cannot collide with yours.

A leading underscore marks something private, both for class members and for module members. The compiler enforces it in both cases.