constant
constant
#
The unified constant node — an inline value of any JSON-backed scalar type.
One Constant node replaces the old per-type constants: it carries any
inline-JSON scalar value (Bool, Number, String, Time,
Location, ...) as that type's JSON encoding, and its return type is the
scalar's type, so any platform decodes the value through the return type. This
is also the seam a server interceptor uses to compute a value of any type at
generation time and drop it straight into the graph.
Constant
#
Bases: Procedure[T]
An inline constant value of a JSON-backed scalar type T.
Construct it from a scalar instance — Constant(value=Number(value=42)) —
or lift a raw value with [const][]. The value is stored as its JSON
encoding and _return_type is taken from the scalar's type.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
Setting[JSONScalar | bool | int | float | str | dict | list]
|
A scalar instance at construction; replaced by its JSON encoding. |
Source code in capturegraph-lib/capturegraph/procedures/nodes/process/constant.py
__post_init__()
#
Resolve _return_type from value and encode it as JSON.
Source code in capturegraph-lib/capturegraph/procedures/nodes/process/constant.py
const(value)
#
Lift a scalar value or instance into a Constant node.
Accepts an existing Constant (returned as-is), any JSONScalar
instance, or a raw bool / int / float / str.