Built-in Functions Overview
These functions are always available. This is the compact overview; the full reference with exact signatures is Built-in Functions.
Output
Section titled “Output”print(values...): print normal text to consolewarn(values...): print an amber warning line to the console’s WARNINGS viewdebug(values...): print low-priority telemetry, hidden from ALL unless debug output is enablednotify(text, level?, duration?): show a toast and archive it in Notifications
type(value): returns value-based categories such asintfor whole numbers,floatfor fractional numbers,str, andbool. Numeric categories use the current value, sotype(4.0)isint.isinstance(value, type): check type/category:isinstance(name, str),isinstance(n, int),isinstance(n, int | float),isinstance(x, (int, str)), or broadisinstance(n, "number")callable(value):Trueif value is a function, method, class, or object with a callable__call__len(value): length of string, list, tuple, dict, or setbool(value): convert toTrue/False
Conversion
Section titled “Conversion”str(value),int(value, base?),float(value)list(value),tuple(value),set(value),dict(...): type constructorschr(code),ord(char)hex(n),bin(n),oct(n): integer to base-prefixed stringrepr(value): debug-friendly string representation
abs(n),round(n, digits?),pow(base, exp)isclose(a, b, rel_tol=0.000000001, abs_tol=0.0): compare floating-point results with an accepted differencemin(values...)/max(values...): args, a list, or a tuplesum(sequence, start=0)/prod(sequence, start=1): add or multiply numeric itemsrandom()/rand(): random float from 0 up to but not including 1randint(min, max): random integer with inclusive boundsimport random: module form withrandom.random(),random.rand(), andrandom.randint(min, max)floor(n),ceil(n),trunc(n),sign(n),divmod(a, b)sqrt(n),exp(n),log(n),log2(n),log10(n)sin(n),cos(n),tan(n),asin,acos,atan,atan2(y, x)degrees(rad),radians(deg)inf: positive infinity; use-inffor negative infinitypi,tau: constants
Sequences
Section titled “Sequences”range(stop)/range(start, stop, step)sorted(sequence, key=fn, reverse=False): new sorted list. Passkey=lambda x: x.valueto sort by a computed field;reverse=Truefor descending.reversed(sequence): new reversed listenumerate(sequence, start=0): list of(index, value)pairszip(sequence1, sequence2, ..., strict=False): combine sequences into pairs;strict=Trueraises if lengths differmap(fn, sequence)/filter(fn, sequence)/reduce(fn, sequence, initializer?): transform, select, or fold itemspairwise(sequence): neighboring(a, b)pairsbatched(sequence, size): fixed-size tuple batchesstarmap(fn, sequence): callfnwith tuple/list items unpacked as argumentsflatten(sequence): flatten one nested levelcount_by(sequence, key_fn?): count values or computed keys into a dictiter(sequence)/next(iterator): manual iterationchain(seq1, seq2, ...): concatenate sequencesaccumulate(sequence): running totalscombinations(sequence, r)/permutations(sequence, r): combinatoricsproduct(seq1, seq2, ...): cartesian product
all(sequence):Trueif every item is truthyany(sequence):Trueif any item is truthy
Modules
Section titled “Modules”import random: random-number helpers (random)from functools import reduce: reducer helper as a module import (functools)import re: regular expressions:search,match,fullmatch,findall,sub, andsplit(re)from dataclasses import dataclass, field: generated record-class construction and field configuration (dataclasses)
Timing
Section titled “Timing”sleep(seconds): intentionally wait before continuing. Loops are paced automatically; use this only when you want game time to pass.
hash(value): hash a string, number, bool,None, tuple-of-hashables, or class instance (identity by default,__hash__when defined)