Data Attributes
The attribute operator (.) can be used to recursively resolve values from a compound native Python data type such as
an object or dictionary. This can be used when the thing which the rule is evaluating has members with their own
submembers. If the resolver function fails, the attribute will be checked to determine if it is a builtin attribute.
Builtin Attributes
The following attributes are builtin to the default Context object.
Attribute Name |
Attribute Type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FLOAT Attributes 1
Due to the syntax of floating point literals, the attributes must be accessed using parenthesis. For example
3.14.to_str is invalid while (3.14).to_str is valid.
Encoding and Decoding
BYTES values can be converted to STRING values by calling their .decode
method. STRING values can be converted to BYTES values by calling their
.encode method. This resembles Python’s native functionality and the encoding argument to each is the same, i.e.
it can be any encoding name that Python can handle such as UTF-8. In addition to the encoding names that Python can
handle, the special names hex, base16 and base64 can be used for transcoding ascii-hex, and base-64
formatted data.
Object Methods
Much like in Python, a method is a function that is associated with an object. They are defined as
FUNCTION values and are accessed as attributes.
BYTES decode(STRING encoding) -> STRING
Returns the decoded value.
Added in version 4.5.0.
STRING encode(STRING encoding) -> BYTES
Returns the encoded value.
Added in version 4.5.0.
ARRAY | BYTES | STRING ends_with(ARRAY | BYTES | STRING suffix) -> BOOLEAN
- returns:
- suffix:
The suffix to check for. The data type must match the object type.
Check whether the value ends with the specified value.
Added in version 4.5.0.
ARRAY | BYTES | STRING starts_with(ARRAY | BYTES | STRING prefix) -> BOOLEAN
- returns:
- prefix:
The prefix to check for. The data type must match the object type.
Check whether the value starts with the specified value.
Added in version 4.5.0.