DictAttribute
Dict interface to attributes.
Attributes
| Attribute | Type | Description |
|---|---|---|
| obj | Any = None | The underlying object whose attributes are being exposed through a dictionary-like interface. |
| iterkeys | callable | A reference to the internal method used to iterate over the attribute names of the wrapped object. |
| iteritems | callable | A reference to the internal method used to iterate over the attribute name and value pairs of the wrapped object. |
| itervalues | callable | A reference to the internal method used to iterate over the attribute values of the wrapped object. |
| items | callable | An alias for the method that provides an iterable of the wrapped object's attribute names and values. |
| keys | callable | An alias for the method that provides an iterable of the wrapped object's attribute names. |
| values | callable | An alias for the method that provides an iterable of the wrapped object's attribute values. |
Constructor
Signature
def DictAttribute(
obj: Any
) - > None
Parameters
| Name | Type | Description |
|---|---|---|
| obj | Any | The object to be wrapped for attribute-to-dictionary interface mapping. |
Signature
def DictAttribute(
obj: Any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| obj | Any | The target object whose attributes will be accessed via dictionary-style keys. |
Methods
get()
@classmethod
def get(
key: Any,
default: Any = None
) - > Any
Attempts to retrieve a value by key, returning a default value if the attribute does not exist.
Parameters
| Name | Type | Description |
|---|---|---|
| key | Any | The attribute name to look up. |
| default | Any = None | The fallback value to return if the attribute is missing from the wrapped object. |
Returns
| Type | Description |
|---|---|
Any | The attribute value if found, otherwise the provided default value. |
setdefault()
@classmethod
def setdefault(
key: Any,
default: Any = None
) - > null
Sets an attribute to a default value only if it does not already exist on the wrapped object.
Parameters
| Name | Type | Description |
|---|---|---|
| key | Any | The attribute name to check and potentially set. |
| default | Any = None | The value to assign if the attribute is currently missing. |
Returns
| Type | Description |
|---|---|
null | None |