AssetNameList
- class cometa.assets.asset_name_list.AssetNameList(ptr=None)[source]
Bases:
Sequence[AssetName]Represents a list of asset names.
Example
>>> name_list = AssetNameList() >>> name_list.add(AssetName.from_string("Token1")) >>> name_list.add(AssetName.from_string("Token2")) >>> len(name_list) 2
- classmethod from_list(names)[source]
Creates an AssetNameList from an iterable of AssetName objects.
- Parameters:
names (Iterable[AssetName]) – An iterable of AssetName objects.
- Returns:
A new AssetNameList containing all the names.
- Raises:
CardanoError – If creation fails.
- Return type:
- add(element)[source]
Adds an asset name to the list.
- Parameters:
element (AssetName) – The asset name to add.
- Raises:
CardanoError – If the operation fails.
- Return type:
None
- get(index)[source]
Retrieves an asset name by index.
- Parameters:
index (int) – The index of the element to retrieve.
- Returns:
The AssetName at the specified index.
- Raises:
CardanoError – If retrieval fails.
IndexError – If index is out of bounds.
- Return type:
- __getitem__(index)[source]
Gets an asset name by index using bracket notation. Supports negative indices.
- Parameters:
index (int)
- Return type:
- __contains__(item)[source]
Checks if an asset name is in the list.
- Parameters:
item (AssetName)
- Return type:
bool
- append(element)[source]
Appends an asset name to the list.
This is an alias for add() to match Python list semantics.
- Parameters:
element (AssetName) – The asset name to append.
- Return type:
None
- index(value, start=0, stop=None)[source]
Returns the index of the first occurrence of value.
- Parameters:
value (AssetName) – The value to search for.
start (int) – Start searching from this index.
stop (int | None) – Stop searching at this index.
- Returns:
The index of the first occurrence.
- Raises:
ValueError – If the value is not found.
- Return type:
int