reflex.vars.Var
An abstract var.
Signature | Description |
---|---|
create(cls, value: 'Any', _var_is_local: 'bool' = True, _var_is_string: 'bool | None' = None, _var_data: 'Optional[VarData]' = None) -> 'Var | None' | Create a var from a value. |
create_safe(cls, value: 'Any', _var_is_local: 'bool' = True, _var_is_string: 'bool | None' = None, _var_data: 'Optional[VarData]' = None) -> 'Var' | Create a var from a value, asserting that it is not None. |
equals(self, other: 'Var') -> 'bool' | Check if two vars are equal. |
to_string(self, json: 'bool' = True) -> 'Var' | Convert a var to a string. |
to_int(self) -> 'Var' | Convert a var to an int. |
operation(self, op: 'str' = '', other: 'Var | None' = None, type_: 'Type | None' = None, flip: 'bool' = False, fn: 'str | None' = None, invoke_fn: 'bool' = False) -> 'Var' | Perform an operation on a var. |
is_valid_operation(operand1_type: 'Type', operand2_type: 'Type', operator: 'str') -> 'bool' | Check if an operation between two operands is valid. |
compare(self, op: 'str', other: 'Var') -> 'Var' | Compare two vars with inequalities. |
length(self) -> 'Var' | Get the length of a list var. |
contains(self, other: 'Any', field: 'Union[Var, None]' = None) -> 'Var' | Check if a var contains the object `other`. |
reverse(self) -> 'Var' | Reverse a list var. Raises: VarTypeError: If the var is not a list. |
lower(self) -> 'Var' | Convert a string var to lowercase. |
upper(self) -> 'Var' | Convert a string var to uppercase. |
strip(self, other: 'str | Var[str]' = ' ') -> 'Var' | Strip a string var. |
split(self, other: 'str | Var[str]' = ' ') -> 'Var' | Split a string var into a list. |
join(self, other: 'str | Var[str] | None' = None) -> 'Var' | Join a list var into a string. |
foreach(self, fn: 'Callable') -> 'Var' | Return a list of components. after doing a foreach on this var. |
range(cls, v1: 'Var | int' = 0, v2: 'Var | int | None' = None, step: 'Var | int | None' = None) -> 'Var' | Return an iterator over indices from v1 to v2 (or 0 to v1). |
to(self, type_: 'Type') -> 'Var' | Convert the type of the var. |
as_ref(self) -> 'Var' | Convert the var to a ref. |
json(self) -> 'str' | Serialize the var to a JSON string. Raises: NotImplementedError: If the method is not implemented. |