Docs

Blog

Gallery

Resources

Learn

Components

API Reference

Onboarding

Api-reference

/

Var

reflex.vars.Var

An abstract var.

FieldDescription
FieldDescription
SignatureDescription
__post_init__(self) -> 'None'Post-initialize the var.
_replace(self, merge_var_data=None, **kwargs: 'Any') -> 'Var'Make a copy of this Var with updated fields.
_decode(self) -> 'Any'Decode Var as a python value. Note that Var with state set cannot be decoded python-side and will be returned as full_name.
equals(self, other: 'Var') -> 'bool'Check if two vars are equal.
_merge(self, other) -> 'Var'Merge two or more dicts.
to_string(self, json: 'bool' = True) -> 'Var'Convert a var to a string.
__hash__(self) -> 'int'Define a hash function for a var.
__str__(self) -> 'str'Wrap the var so it can be used in templates.
__bool__(self) -> 'bool'Raise exception if using Var in a boolean context. Raises: TypeError: when attempting to bool-ify the Var.
__iter__(self) -> 'Any'Raise exception if using Var in an iterable context. Raises: TypeError: when attempting to iterate over the Var.
__format__(self, format_spec: 'str') -> 'str'Format the var into a Javascript equivalent to an f-string.
__getitem__(self, i: 'Any') -> 'Var'Index into a var.
__getattr__(self, name: 'str') -> 'Var'Get a var attribute.
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.
__invert__(self) -> 'Var'Invert a var.
__neg__(self) -> 'Var'Negate a var.
__abs__(self) -> 'Var'Get the absolute value of a var.
length(self) -> 'Var'Get the length of a list var.
_type(self) -> 'Var'Get the type of the Var in Javascript.
__eq__(self, other: 'Union[Var, Type]') -> 'Var'Perform an equality comparison.
__ne__(self, other: 'Union[Var, Type]') -> 'Var'Perform an inequality comparison.
__gt__(self, other: 'Var') -> 'Var'Perform a greater than comparison.
__ge__(self, other: 'Var') -> 'Var'Perform a greater than or equal to comparison.
__lt__(self, other: 'Var') -> 'Var'Perform a less than comparison.
__le__(self, other: 'Var') -> 'Var'Perform a less than or equal to comparison.
__add__(self, other: 'Var', flip=False) -> 'Var'Add two vars.
__radd__(self, other: 'Var') -> 'Var'Add two vars.
__sub__(self, other: 'Var') -> 'Var'Subtract two vars.
__rsub__(self, other: 'Var') -> 'Var'Subtract two vars.
__mul__(self, other: 'Var', flip=True) -> 'Var'Multiply two vars.
__rmul__(self, other: 'Var') -> 'Var'Multiply two vars.
__pow__(self, other: 'Var') -> 'Var'Raise a var to a power.
__rpow__(self, other: 'Var') -> 'Var'Raise a var to a power.
__truediv__(self, other: 'Var') -> 'Var'Divide two vars.
__rtruediv__(self, other: 'Var') -> 'Var'Divide two vars.
__floordiv__(self, other: 'Var') -> 'Var'Divide two vars.
__mod__(self, other: 'Var') -> 'Var'Get the remainder of two vars.
__rmod__(self, other: 'Var') -> 'Var'Get the remainder of two vars.
__and__(self, other: 'Var') -> 'Var'Perform a logical and.
__rand__(self, other: 'Var') -> 'Var'Perform a logical and.
__or__(self, other: 'Var') -> 'Var'Perform a logical or.
__ror__(self, other: 'Var') -> 'Var'Perform a logical or.
__contains__(self, _: 'Any') -> 'Var'Override the 'in' operator to alert the user that it is not supported. Raises: TypeError: the operation is not supported
contains(self, other: 'Any') -> 'Var'Check if a var contains the object `other`.
reverse(self) -> 'Var'Reverse a list var. Raises: TypeError: 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.
to(self, type_: 'Type') -> 'Var'Convert the type of the var.
as_ref(self) -> 'Var'Convert the var to a ref.
_var_set_state(self, state: 'Type[BaseState] | str') -> 'Any'Set the state of the var.

Did you find this useful?

HomeGalleryChangelogIntroductionHosting