Builtin names
Every name a module has bound by default, by section. Each entry links
to the page that documents it. A name can answer in more than one
section – try is a layout handler and a special form, + a special
form and an operator function – and
Names with more than one meaning
lists each of those with all its pages.
Layout handlers: block heads that read an indented block into a form
Special forms: forms the compiler handles directly
Macros: forms that expand to special forms
Fences: triple-backtick foreign literals
Runtime: types and type predicates, operators, functions, and exceptions
Layout handlers
Head |
Peers |
Reads to |
|---|---|---|
|
||
|
||
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
||
|
||
|
||
the block of the word after |
||
a |
||
a |
||
a |
||
a |
||
a |
||
a |
||
|
Special forms
Definition and binding
Form |
Does |
|---|---|
Bind a name in the current scope, with an optional type, or several names by unpacking |
|
The Scheme-layer spelling of |
|
Bind a name at the module from any depth; what |
|
Bind the names of a pattern in the current scope; what |
|
Bind the names of a pattern at the module; what |
|
A named function value that is not bound |
|
An anonymous function value; formals, defaults, rest collectors, annotations, by-ref |
|
Lexical bindings for a body; named |
|
Lexical bindings that may refer to each other |
|
Store into an existing binding; the special under |
|
Store into several bindings by unpacking |
|
Bind a name to a ref |
|
The ref of a variable; the special under |
|
Read through a ref |
|
Read a binding and clear it |
|
Delete a binding |
|
The module namespace; the current scope’s namespace, or an object’s |
|
Read a dynamic parameter; rebind parameters for a body |
Control flow
Form |
Does |
|---|---|
Run forms in order; the value is the last |
|
The first clause whose test is true; what layout |
|
Branch on equality against candidates |
|
Destructure against patterns; see Match patterns |
|
Short-circuit conjunction and disjunction |
|
Loop while a test is true, with an |
|
Loop over an iterable, with destructuring and an |
|
Leave a loop, with an optional value; start the next iteration |
|
Leave a function; several values return a tuple, keywords a |
|
Handle exceptions, with |
|
Raise an exception, or re-raise the current one |
|
Internal forms that |
Objects, attributes, and items
Form |
Does |
|---|---|
Read, store, delete an attribute; |
|
A ref to an attribute; take and delete; update in place |
|
Read, store, delete a subscript; |
|
A ref to a subscript; take and delete; update in place |
|
Update a variable in place; the special under |
|
Call a value; forces a runtime call past a same-named macro |
|
Call a method by name; |
|
Build a class value without binding a name; what |
|
Type tests; a tuple as the second operand tests several types |
|
String conversion; |
|
Build a list or tuple; append to a list |
Operators
Form |
Does |
|---|---|
|
Equality, chained over any number of operands |
Ordering, chained |
|
Aliases for |
|
Exponentiation with an optional modulus |
|
Membership and identity, each with a |
|
|
The unary and inspection operators |
The arithmetic, bitwise, and unary operators, constant folding, and the comparison table |
Pairs and quoting
Form |
Does |
|---|---|
Build a pair chain; its first element; its rest |
|
Build a bracket pair chain; a proper bracket list |
|
A form as data; |
|
A form as data, keeping hygiene marks; |
|
A template; |
|
A template keeping hygiene marks; |
|
The reader shorthands |
Async, generators, and continuations
Form |
Does |
|---|---|
Await a held awaitable; bare |
|
Generator and coroutine suspension; delegation |
|
Context managers, lexical and dynamic-extent |
|
Before and after thunks around a body, rerun across continuation jumps |
|
Delimited continuations |
|
Undelimited continuations, from the Scheme form down to the raw capture |
Modules
Form |
Does |
|---|---|
Import a module; |
|
Import names from a module, with aliases |
|
Bind a module’s public names, at module level only |
|
Import a feature with all its facets, a macro together with its runtime sibling |
Macro definition and the compiler
Form |
Does |
|---|---|
Template transformers, by rule list and by named spec |
|
Procedural transformers |
|
Transformers that receive the compiler and emit bytecode |
|
The arm used when a syntax name appears as a lone atom |
|
The |
|
Expand a fenced foreign literal through its handler |
|
Inject bytecode directly |
Operator names
Form |
Does |
|---|---|
Arithmetic and bitwise operators |
|
|
Comparison operators and their aliases |
Membership and identity operators and their aliases |
Macros
Binding and assignment
Macro |
Does |
|---|---|
Store into a name, attribute, subscript, or ref, choosing the special by target shape |
|
Add to or subtract from a binding in place |
|
Delete a name, attribute, or subscript |
|
Read a name, attribute, or subscript and clear it |
|
Bind a name to a ref, typed by the target shape |
|
A ref to a name, attribute, subscript, or parameter |
|
Whether a location holds a value; store one unless it already does |
|
Sequential |
|
|
|
Local functions for a body, mutually recursive and not |
|
Declare a dynamic parameter |
|
Bind a name to an environment variable |
|
Name the module’s public features |
|
Mark the function a program runs once its module has loaded |
Conditionals
Macro |
Does |
|---|---|
Two-armed conditional over |
|
One-armed conditionals |
|
Conditional with a boolean default |
|
Truthiness as a boolean |
|
Identity test against the |
|
Membership |
|
Raise |
|
A no-op expression, and a bare control word |
Definitions
Macro |
Does |
|---|---|
Define a function and bind it in the current scope |
|
Prefix over |
|
Define a class and bind it in the current scope |
|
The superclass proxy inside a method |
|
What |
|
Python’s |
Iteration and collections
Macro |
Does |
|---|---|
A generator over a |
|
A list from the same shape |
|
A dict from |
|
A slice object; a slice of a sequence |
|
Nested item and attribute chains |
|
Positions in a pair chain |
|
Compose functions right to left |
Macros about macros
Macro |
Does |
|---|---|
A transformer bound at the module from top level, or for the rest of a body inside one |
|
The Scheme-layer spelling: a transformer bound at the module, with any of the rule and match kinds or a bare form; its template names are kept apart from the use site, see Hygiene |
|
Add arms to an existing transformer |
|
A transformer scoped to a body |
|
Run a body at expand time and splice its result |
|
Capture a form with its source position for hygiene |
|
The same without evaluating the argument; in a template, writes a form raw ( |
|
Define a fence handler for a triple-backtick literal |
|
Expand a form fully, or by one step |
|
The same without quoting the form |
|
Compile, evaluate, and reach the compiler from a program |
|
Set or read a module’s reader and compiler settings |
|
Documentation for a name |
Fences
Name |
Does |
|---|---|
A bash script as a literal, run through |
Runtime
Types and type predicates
Each type is bound with its NAME? predicate: int and int?,
list and list?, and so on.
Name |
Does |
|---|---|
Numbers |
|
Text and bytes |
|
Collections |
|
Objects and classes |
|
Pairs and symbols |
|
Functions and results |
|
Iterators |
|
|
Refs |
The result of |
Operators
Name |
Does |
|---|---|
Arithmetic and bitwise |
|
|
Comparison, chained |
Membership and identity |
Functions
Name |
Does |
|---|---|
|
Predicates |
Pairs |
|
Collection builders |
|
|
Calling |
Async |
|
|
Iteration |
|
Conversion and display |
Input and output |
|
Attributes and items |
|
Refs, parameters, and the environment |
|
Compilation and expansion |
|
|
Constants |
Exceptions
Name |
Does |
|---|---|
The Koskari exceptions; every Python exception type is bound as well |
Names with more than one meaning
Name |
Meanings |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|