Skip to content

ElementAttribute

ElementAttribute(name, attribute_type)

Bases: TM1Object

Abstraction of TM1 Element Attributes

Source code in TM1py/Objects/ElementAttribute.py
def __init__(self, name: str, attribute_type: Union[Types, str]):
    self.name = name
    self.attribute_type = attribute_type

attribute_type property writable

body property

body_as_dict property

name property writable

Types

Bases: Enum

ALIAS = 3 class-attribute instance-attribute

NUMERIC = 1 class-attribute instance-attribute

STRING = 2 class-attribute instance-attribute

__str__()

Source code in TM1py/Objects/ElementAttribute.py
def __str__(self):
    return self.name.capitalize()

__eq__(other)

Source code in TM1py/Objects/ElementAttribute.py
def __eq__(self, other: Union[str, "ElementAttribute"]):
    if isinstance(other, str):
        return case_and_space_insensitive_equals(self.name, other)
    elif isinstance(other, ElementAttribute):
        return case_and_space_insensitive_equals(self.name, other.name)
    else:
        raise ValueError("Argument: 'other' must be of type str or ElementAttribute")

__hash__()

Source code in TM1py/Objects/ElementAttribute.py
def __hash__(self):
    return super().__hash__()

from_dict(element_attribute_as_dict) classmethod

Source code in TM1py/Objects/ElementAttribute.py
@classmethod
def from_dict(cls, element_attribute_as_dict: Dict) -> "ElementAttribute":
    return cls(name=element_attribute_as_dict["Name"], attribute_type=element_attribute_as_dict["Type"])

from_json(element_attribute_as_json) classmethod

Source code in TM1py/Objects/ElementAttribute.py
@classmethod
def from_json(cls, element_attribute_as_json: str) -> "ElementAttribute":
    return cls.from_dict(json.loads(element_attribute_as_json))