builtins¶
Supported Python builtins.
abs(x: builtins.int | builtins.float) -> builtins.int | builtins.float
¶
Return the absolute value of a number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int | float
|
A number. |
required |
Returns:
| Type | Description |
|---|---|
int | float
|
The absolute value of x. |
all(iterable: Iterable[builtins.bool]) -> builtins.bool
¶
Return True if all elements of the iterable are true.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable[bool]
|
The iterable to evaluate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if all elements are true, False otherwise. |
any(iterable: Iterable[builtins.bool]) -> builtins.bool
¶
Return True if any element of the iterable is true.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable[bool]
|
The iterable to evaluate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if any element is true, False otherwise. |
bool(x: object = False) -> builtins.bool
¶
Convert a value to a Boolean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
object
|
The value to convert. Defaults to False if omitted. |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
The Boolean value of x. |
callable(obj: object) -> builtins.bool
¶
Check if the object appears callable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
object
|
The object to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the object appears callable, False otherwise. |
dict(*args, **kwargs) -> builtins.dict
¶
dict() -> builtins.dict
dict(
mapping: builtins.dict[K, V], **kwargs: V
) -> builtins.dict[K, V]
dict(
iterable: Iterable[tuple[K, V]], **kwargs: V
) -> builtins.dict[K, V]
dict(**kwargs: V) -> builtins.dict[builtins.str, V]
Construct a dict from a mapping, an iterable of key-value pairs, or keyword arguments.
All dict keys must be compile-time constants. Dynamic access using a key that is not a compile-time constant is only supported for numeric, Array, and Record values.
Accepts an optional dict to copy from or an iterable of (key, value) pairs, plus
optional keyword arguments to include in the dict.
Returns:
| Type | Description |
|---|---|
dict
|
A new dict. |
enumerate(iterable: Iterable[T], start: builtins.int = 0) -> Iterator[tuple[builtins.int, T]]
¶
Return an enumerate object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable[T]
|
The iterable to enumerate. |
required |
start
|
int
|
The starting index. |
0
|
Returns:
| Type | Description |
|---|---|
Iterator[tuple[int, T]]
|
An enumerate object. |
filter(function: Callable[[T], builtins.bool] | None, iterable: Iterable[T]) -> Iterator[T]
¶
Construct an iterator from those elements of iterable for which function returns true.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
Callable[[T], bool] | None
|
A function that tests if each element should be included. If None, returns the elements that are true. |
required |
iterable
|
Iterable[T]
|
The iterable to filter. |
required |
Returns:
| Type | Description |
|---|---|
Iterator[T]
|
An iterator yielding the filtered elements. |
float(x: builtins.int | builtins.float = 0.0) -> builtins.float
¶
Convert a number to a floating point number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int | float
|
The number to convert. Defaults to 0.0 if omitted. |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
The floating point representation of x. |
getattr(obj: object, name: builtins.str, default: Any = ...) -> Any
¶
getattr(obj: object, name: builtins.str) -> Any
getattr(
obj: object, name: builtins.str, default: T
) -> Any | T
Get a named attribute from an object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
object
|
The object to get the attribute from. |
required |
name
|
str
|
The name of the attribute. |
required |
default
|
Any
|
The value to return if the attribute does not exist. |
...
|
Returns:
| Type | Description |
|---|---|
Any
|
The value of the attribute, or default if it does not exist. |
hasattr(obj: object, name: builtins.str) -> builtins.bool
¶
Check if an object has a named attribute.
Can result in a compile-time error if an unsupported property is checked, since later trying to access it would also fail.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
object
|
The object to check. |
required |
name
|
str
|
The name of the attribute. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the object has the attribute, False otherwise. |
int(x: builtins.int | builtins.float = 0) -> builtins.int
¶
Convert a number to an integer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int | float
|
The number to convert. Defaults to 0 if omitted. |
0
|
Returns:
| Type | Description |
|---|---|
int
|
The integer representation of x. |
isinstance(obj: object, classinfo: type | tuple[type, ...]) -> builtins.bool
¶
Check if an object is an instance of a class or of a subclass thereof.
classinfo may be a single type or a tuple of types. Checking against int, float, or bool directly is not
supported; use Num instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
object
|
The object to check. |
required |
classinfo
|
type | tuple[type, ...]
|
A type or a tuple of types. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the object is an instance of classinfo, False otherwise. |
issubclass(cls: type, classinfo: type | tuple[type, ...]) -> builtins.bool
¶
Check if a class is a subclass of another class or a tuple of classes.
Both arguments must be types known at compile time. classinfo may be a single type or a tuple of types.
Checking against int, float, or bool directly is not supported; use Num instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type
|
The class to check. |
required |
classinfo
|
type | tuple[type, ...]
|
A class or a tuple of classes. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if cls is a subclass of classinfo, False otherwise. |
iter(iterable: Iterable[T]) -> Iterator[T]
¶
Return an iterator for the given iterable.
Not supported for a tuple, dict, set, or enum class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable[T]
|
The iterable to convert to an iterator. |
required |
Returns:
| Type | Description |
|---|---|
Iterator[T]
|
An iterator over the elements of the iterable. |
len(s: object) -> builtins.int
¶
Return the number of items in a container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
object
|
The container object. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The number of items in s. |
map(function: Callable[..., S], iterable: Iterable[T], *iterables: Iterable[Any]) -> Iterator[S]
¶
Apply a function to every item of an iterable and return an iterator.
A tuple, dict, set, or enum class may be used, but every argument must be one of those, or none may be;
mixing them with other iterables raises an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
Callable[..., S]
|
The function to apply. |
required |
iterable
|
Iterable[T]
|
The iterable to process. |
required |
*iterables
|
Iterable[Any]
|
Additional iterables to process in parallel with iterable. |
()
|
Returns:
| Type | Description |
|---|---|
Iterator[S]
|
An iterator with the results. |
max(*args, **kwargs)
¶
max(
iterable: Iterable[T],
*,
key: Callable[[T], Any] | None = ...,
) -> T
max(
iterable: Iterable[T],
*,
default: T = ...,
key: Callable[[T], Any] | None = ...,
) -> T
max(
arg1: builtins.int | builtins.float,
arg2: builtins.int | builtins.float,
*args: builtins.int | builtins.float,
key: Callable[[builtins.int | builtins.float], Any]
| None = ...,
) -> builtins.int | builtins.float
Return the largest item in an iterable or the largest of multiple arguments.
When called with a single iterable, returns the largest item from that iterable. When called with two or more arguments, all arguments must be numbers, and the largest one is returned.
Use the key parameter to specify a function that transforms each element before comparison.
A tuple, dict, set, or enum class argument is only supported when every element is numeric; use an
Array or VarArray for a collection of other types.
The default parameter specifies a value to return if the iterable is empty. It is not supported when called
with multiple arguments, and it must be usable in place of an element. When the iterable's length is not known
at compile time, the choice between an element and default is made at runtime, which only numbers support,
so a Record or Array element type fails to compile there.
min(*args, **kwargs)
¶
min(
iterable: Iterable[T],
*,
key: Callable[[T], Any] | None = ...,
) -> T
min(
iterable: Iterable[T],
*,
default: T = ...,
key: Callable[[T], Any] | None = ...,
) -> T
min(
arg1: builtins.int | builtins.float,
arg2: builtins.int | builtins.float,
*args: builtins.int | builtins.float,
key: Callable[[builtins.int | builtins.float], Any]
| None = ...,
) -> builtins.int | builtins.float
Return the smallest item in an iterable or the smallest of multiple arguments.
When called with a single iterable, returns the smallest item from that iterable. When called with two or more arguments, all arguments must be numbers, and the smallest one is returned.
Use the key parameter to specify a function that transforms each element before comparison.
A tuple, dict, set, or enum class argument is only supported when every element is numeric; use an
Array or VarArray for a collection of other types.
The default parameter specifies a value to return if the iterable is empty. It is not supported when called
with multiple arguments, and it must be usable in place of an element. When the iterable's length is not known
at compile time, the choice between an element and default is made at runtime, which only numbers support,
so a Record or Array element type fails to compile there.
next(iterator: Iterator[T]) -> T
¶
Retrieve the next item from an iterator.
Errors if the iterator is exhausted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterator
|
Iterator[T]
|
The iterator to retrieve the next item from. |
required |
Returns:
| Type | Description |
|---|---|
T
|
The next item from the iterator. |
range(*args) -> builtins.range
¶
range(stop: builtins.int) -> builtins.range
range(
start: builtins.int,
stop: builtins.int,
step: builtins.int = ...,
) -> builtins.range
Return an immutable sequence of numbers.
When called with one argument, creates a sequence from 0 to that number (exclusive). When called with two arguments, creates a sequence from the first to the second (exclusive). When called with three arguments, the third argument specifies the step size.
reversed(seq: Sequence[T]) -> Iterator[T]
¶
Return a reverse iterator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seq
|
Sequence[T]
|
The sequence to reverse. |
required |
Returns:
| Type | Description |
|---|---|
Iterator[T]
|
An iterator over the reversed sequence. |
round(number: builtins.int | builtins.float, ndigits: builtins.int = ...) -> builtins.float
¶
Round a number to a given precision in decimal digits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
int | float
|
The number to round. |
required |
ndigits
|
int
|
The number of decimal digits to round to. |
...
|
Returns:
| Type | Description |
|---|---|
float
|
The rounded number. |
set(*args) -> builtins.set
¶
set() -> builtins.set
set(iterable: Iterable[T]) -> builtins.set[T]
Construct a set from an iterable.
All set members must be compile-time constants. Accepts an optional tuple, dict, enum class, or set.
An Array, VarArray, or range is not accepted.
Returns:
| Type | Description |
|---|---|
set
|
A new set. |
setattr(obj: object, name: builtins.str, value: Any) -> None
¶
Set a named attribute on an object.
The attribute must already exist as a supported field or property; setting an unsupported name is a compile-time error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
object
|
The object to set the attribute on. |
required |
name
|
str
|
The name of the attribute. |
required |
value
|
Any
|
The value to set. |
required |
sum(iterable: Iterable[builtins.int | builtins.float], /, start: builtins.int | builtins.float = 0) -> builtins.int | builtins.float
¶
Return the sum of a 'start' value (default: 0) and an iterable of numbers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable[int | float]
|
The iterable of numbers to sum. |
required |
start
|
int | float
|
The starting value to add to the sum. |
0
|
Returns:
| Type | Description |
|---|---|
int | float
|
The total sum. |
super(cls: type = ..., instance: Any = ...) -> Any
¶
Return a proxy object that delegates method calls to a parent or sibling class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type
|
The class to delegate. |
...
|
instance
|
Any
|
The instance to delegate to. |
...
|
Returns:
| Type | Description |
|---|---|
Any
|
A proxy object that can be used to call methods from the parent or sibling class. |
type(obj: object) -> builtins.type
¶
Return the type of an object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
object
|
The object to get the type of. |
required |
Returns:
| Type | Description |
|---|---|
type
|
The type of the object. |
zip(*iterables: Iterable[T], strict: Literal[False] = False) -> Iterator[tuple[T, ...]]
¶
Return an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*iterables
|
Iterable[T]
|
Iterables to aggregate. |
()
|
strict
|
Literal[False]
|
Must be False; strict zipping is not currently supported. |
False
|
Returns:
| Type | Description |
|---|---|
Iterator[tuple[T, ...]]
|
An iterator of aggregated tuples. |