non_data_variable
NonDataVariable
from dara.core.interactivity.non_data_variable import NonDataVariable
class NonDataVariable(AnyVariable, abc.ABC)
NonDataVariable represents any variable that is not specifically designed to hold datasets (i.e. Variable, DerivedVariable, UrlVariable)
Arguments:
uid
: the unique identifier for this variable; if not provided a random one is generated
Attributes
- uid: str
Methods
list_item
@property
def list_item()
Get a LoopVariable that represents the current item in the list.
Should only be used in conjunction with the For
component.
Note that it is a type of a Variable so it can be used in places where a regular Variable is expected.
By default, the entire list item is used as the item.
LoopVariable
supports nested property access using get
or index access i.e. []
.
You can mix and match those two methods to access nested properties as they are equivalent.
my_list = Variable(['foo', 'bar', 'baz'])
# Represents the entire item in the list
my_list.list_item
my_list_of_objects = Variable([
{'id': 1, 'name': 'John', 'data': {'city': 'London', 'country': 'UK'}},
{'id': 2, 'name': 'Jane', 'data': {'city': 'Paris', 'country': 'France'}},
])
# Represents the item 'name' property
my_list_of_objects.list_item['name']
# Represents the item 'data.country' property
my_list_of_objects.list_item.get('data')['country']