datahold

Version:

Overview

This project wraps common mutable datastructures for inheritance with modification.

Installation
Features
class datahold.HoldABC(*args: Any, **kwargs: Any)
class HoldABC(ABC):

    __slots__ = ("_data",)

    __hash__ = unhash

    @abstractmethod
    def __init__(self: Self, *args: Any, **kwargs: Any) -> None: 
        "This magic method initializes self."
        ...

    @classmethod
    def __subclasshook__(cls: type, other: type, /) -> bool:
        "This magic classmethod can be overwritten for a custom subclass check."
        return NotImplemented

    @property
    @abstractmethod
    def data(self: Self) -> Any: ...
class datahold.HoldDict(*args: Any, **kwargs: Any)

This class is a brute wrapper for dict. It inherits from HoldABC and collections.abc.MutableMapping . Its constructor passes all arguments to the constructor of dict and the result is saved within the data property.

__contains__(key: Any, /) -> Any

This magic method implements the in operator. Internally its code is equivalent to the following:

def __contains__(self: Self, key: Any, /) -> Any:
    "True if the dictionary has the specified key, else False."
    data = self.data
    ans = data.__contains__(*args, **kwargs)
    self.data = data
    return ans

The imprecise annotations and docstring are due to it adhering to the underlying dict.__contains__ as closely as possible.

__delitem__(key: Any, /) -> Any

This magic method implements the deletion of items. Its inner workings are analogous to __contains__ .

__eq__(value: Any, /) -> Any

This magic method implements the == operator. Its inner workings are analogous to __contains__ .

__format__(format_spec: Any, /) -> Any

This magic method implements the inbuilt format function. Its inner workings are analogous to __contains__ .

__ge__(value: Any, /) -> Any

This magic method implements the >= operator. Its inner workings are analogous to __contains__ .

__getitem__(key: Any, /) -> Any

This magic method implements the returning of items. Its inner workings are analogous to __contains__ .

__gt__(value: Any, /) -> Any

This magic method implements the > operator. Its inner workings are analogous to __contains__ .

__hash__() -> int

This magic method implements the inbuilt function hash. Its function is unhash.unhash . It always raises a TypeError.

__ior__(value: Any, /) -> Any

This magic method implements the |= operator. Its inner workings are analogous to __contains__ .

__iter__() -> Any

This magic method implements iteration. Its inner workings are analogous to __contains__ .

__le__(value: Any, /) -> Any

This magic method implements the <= operator. Its inner workings are analogous to __contains__ .

__len__() -> Any

This magic method implements the inbuilt len function. Its inner workings are analogous to __contains__ .

__lt__(value: Any, /) -> Any

This magic method implements the < operator. Its inner workings are analogous to __contains__ .

__or__(value: Any, /) -> Any

This magic method implements the | operator. Its inner workings are analogous to __contains__ .

__repr__() -> Any

This magic method implements representation. Its inner workings are analogous to __contains__ .

__reversed__() -> Any

This magic method implements the inbuilt reversed function. Its inner workings are analogous to __contains__ .

__ror__(value: Any, /) -> Any

This magic method implements the | operator from the right side if the left operand does not have it implemented. Its inner workings are analogous to __contains__ .

__setitem__(key: Any, value: Any, /) -> Any

This magic method implements the setting of items. Its inner workings are analogous to __contains__ .

__str__() -> Any

This magic method implements the explicit conversion into a string. Its inner workings are analogous to __contains__ .

__subclasshook__(other: type, /) -> bool

This classmethod is inherited directly from HoldABC .

clear() -> Any

This method deletes of all items. Its inner workings are analogous to __contains__ .

copy() -> Any

This method implements dublication. Its inner workings are analogous to __contains__ . Remember that because of that a dict is returned.

data: dict
This property is implemented with the equivalent to the following code:
                                        @property
def data(self: Self) -> dict:
    return dict(self._data)

@data.setter
def data(self: Self, value: Any) -> None:
    self._data = dict(value)

@data.deleter
def data(self: Self) -> None:
    self._data = dict()
get(key: Any, default: Any = None, /) -> Any

This method implements getting an item with a default in case of its absence. Its inner workings are analogous to __contains__ .

items() -> Any

This method returns an iterator over the items. Its inner workings are analogous to __contains__ .

keys() -> Any

This method returns an iterator over the keys. Its inner workings are analogous to __contains__ .

popitem() -> Any

This method deletes and returns the last item. Its inner workings are analogous to __contains__ .

setdefault(key: Any, default: Any = None, /) -> Any

This method ensures the presence of a key. Its inner workings are analogous to __contains__ .

update(*args: Any, **kwargs: Any) -> Any

This method updates the data. Its inner workings are analogous to __contains__ .

values() -> Any

This method returns an iterator over the values. Its inner workings are analogous to __contains__ .

class datahold.HoldList(*args: Any, **kwargs: Any)

This class is analogous to HoldDict . It implements the magic methods __add__, __contains__, __delitem__, __eq__, __format__, __ge__, __getitem__, __gt__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __repr__, __reversed__, __rmul__, __setitem__, and __str__. The other methods implemented are append, clear, copy, count, extend, index, insert, pop, remove, reverse, and sort. It is a child of HoldABC and of collections.abc.MutableSequence , thereby also inheriting their members.

class datahold.HoldSet(*args: Any, **kwargs: Any)

This class is analogous to HoldDict . It implements the magic methods __and__, __contains__, __eq__, __format__, __ge__, __gt__, __iand__, __ior__, __isub__, __iter__, __le__, __len__, __lt__, __or__, __rand__, __repr__, __ror__, __rsub__, __rxor__, __str__, __sub__, __rmul__, __sub__, and __xor__. The other methods implemented are add, clear, copy, difference, difference_update, discard, intersection, intersection_update, isdisjoint, issubset, issuperset, pop, remove, symmetric_difference, symmetric_difference_update, union, and update. It is a child of HoldABC and of collections.abc.MutableSet , thereby also inheriting their members.

class datahold.OkayABC(*args: Any, **kwargs: Any)

A common ABC for OkayList, OkayDict, and OkaySet. Child of Scaevola and HoldABC . It implements common-sense overwrites for some methods. For example:

  • All methods that cannot actually change the underlying object are now bound to _data instead of data.
  • __bool__ is implemented as bool(self._data) because neither list, dict, nor set have a __bool__ method defined.
  • The comparison operations are overwritten:
    • __eq__ returns self._data == type(self._data)(other).
    • __ne__ negates __eq__.
    • __ge__ returns type(self)(other) <= self (inherited from scaevola.Scaevola).
    • __gt__ returns not (self == other) and (self >= other).
    • __lt__ returns not (self == other) and (self <= other).
    • __le__ returns self._data <= type(self)(other)._data.

Modify __eq__ or __le__ as needed to change the behavior of the other comparison methods.

class datahold.OkayDict(data: Iterable = (), /, **kwargs: Any)

A subclass of HoldDict with common-sense implementations for further inheritance, just like OkayList for HoldList.

class datahold.OkayList(data: Iterable = ())

This class inherits from HoldList and OkayABC. It implements a data property that binds a variable _data.

    @property
    def data(self, /):
        return list(self._data)

    @data.setter
    def data(self, values, /):
        self._data = list(values)

    @data.deleter
    def data(self, /):
        self._data = list()

Based on this, it implements common-sense methods. For example:

  • All methods that returned a list before now return OkayList (type adapts to further inheritance).
  • __init__ allows setting data immediately.
class datahold.OkaySet(data: Iterable = ())

A subclass of HoldSet with common-sense implementations for further inheritance, just like OkayList for HoldList.

class datahold.DataABC(*args: Any, **kwargs: Any)
__hash__() -> int

This magic method implements the inbuilt function hash. Its function is unhash.unhash. It always raises a TypeError.

__subclasshook__(other: type, /) -> bool
data: Any

This abstract property acts as the linchpin of all decending classes.

class datahold.DataDict(*args: Any, **kwargs: Any)

This class is a brute wrapper for dict. It inherits from DataABC and collections.abc.MutableMapping . Its constructor passes all arguments to the constructor of dict and the result is saved within the data property.

__contains__(key: Any, /) -> Any

This magic method implements the in operator. Internally its code is equivalent to the following:

def __contains__(self: Self, key: Any, /) -> Any:
    "True if the dictionary has the specified key, else False."
    data = dict(self.data)
    ans = data.__contains__(*args, **kwargs)
    self.data = frozendict(data)
    return ans

The imprecise annotations and docstring are due to it adhering to the underlying dict.__contains__ as closely as possible.

__delitem__(key: Any, /) -> Any

This magic method implements the deletion of items. Its inner workings are analogous to __contains__ .

__eq__(value: Any, /) -> Any

This magic method implements the == operator. Its inner workings are analogous to __contains__ .

__format__(format_spec: Any, /) -> Any

This magic method implements the inbuilt format function. Its inner workings are analogous to __contains__ .

__ge__(value: Any, /) -> Any

This magic method implements the >= operator. Its inner workings are analogous to __contains__ .

__getitem__(key: Any, /) -> Any

This magic method implements the returning of items. Its inner workings are analogous to __contains__ .

__gt__(value: Any, /) -> Any

This magic method implements the > operator. Its inner workings are analogous to __contains__ .

__hash__() -> int

This magic method implements the inbuilt function hash. Its function is unhash.unhash . It always raises a TypeError.

__ior__(value: Any, /) -> Any

This magic method implements the |= operator. Its inner workings are analogous to __contains__ .

__iter__() -> Any

This magic method implements iteration. Its inner workings are analogous to __contains__ .

__le__(value: Any, /) -> Any

This magic method implements the <= operator. Its inner workings are analogous to __contains__ .

__len__() -> Any

This magic method implements the inbuilt len function. Its inner workings are analogous to __contains__ .

__lt__(value: Any, /) -> Any

This magic method implements the < operator. Its inner workings are analogous to __contains__ .

__or__(value: Any, /) -> Any

This magic method implements the | operator. Its inner workings are analogous to __contains__ .

__repr__() -> Any

This magic method implements representation. Its inner workings are analogous to __contains__ .

__reversed__() -> Any

This magic method implements the inbuilt reversed function. Its inner workings are analogous to __contains__ .

__ror__(value: Any, /) -> Any

This magic method implements the | operator from the right side if the left operand does not have it implemented. Its inner workings are analogous to __contains__ .

__setitem__(key: Any, value: Any, /) -> Any

This magic method implements the setting of items. Its inner workings are analogous to __contains__ .

__str__() -> Any

This magic method implements the explicit conversion into a string. Its inner workings are analogous to __contains__ .

__subclasshook__(other: type, /) -> bool

This classmethod is inherited directly from DataABC .

clear() -> Any

This method deletes of all items. Its inner workings are analogous to __contains__ .

copy() -> Any

This method implements dublication. Its inner workings are analogous to __contains__ . Remember that because of that a dict is returned.

get(key: Any, default: Any = None, /) -> Any

This method implements getting an item with a default in case of its absence. Its inner workings are analogous to __contains__ .

items() -> Any

This method returns an iterator over the items. Its inner workings are analogous to __contains__ .

keys() -> Any

This method returns an iterator over the keys. Its inner workings are analogous to __contains__ .

popitem() -> Any

This method deletes and returns the last item. Its inner workings are analogous to __contains__ .

setdefault(key: Any, default: Any = None, /) -> Any

This method ensures the presence of a key. Its inner workings are analogous to __contains__ .

update(*args: Any, **kwargs: Any) -> Any

This method updates the data. Its inner workings are analogous to __contains__ .

values() -> Any

This method returns an iterator over the values. Its inner workings are analogous to __contains__ .

class datahold.DataList(*args: Any, **kwargs: Any)

This class is analogous to DataDict . It implements the magic methods __add__, __contains__, __delitem__, __eq__, __format__, __ge__, __getitem__, __gt__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __repr__, __reversed__, __rmul__, __setitem__, and __str__. The other methods implemented are append, clear, copy, count, extend, index, insert, pop, remove, reverse, and sort. It is a child of DataABC and of collections.abc.MutableSequence , thereby also inheriting their members.

class datahold.DataSet(*args: Any, **kwargs: Any)

This class is analogous to DataDict . It implements the magic methods __and__, __contains__, __eq__, __format__, __ge__, __gt__, __iand__, __ior__, __isub__, __iter__, __le__, __len__, __lt__, __or__, __rand__, __repr__, __ror__, __rsub__, __rxor__, __str__, __sub__, __rmul__, __sub__, and __xor__. The other methods implemented are add, clear, copy, difference, difference_update, discard, intersection, intersection_update, isdisjoint, issubset, issuperset, pop, remove, symmetric_difference, symmetric_difference_update, union, and update. It is a child of DataABC and of collections.abc.MutableSet , thereby also inheriting their members.

class datahold.HoldABC(*args: Any, **kwargs: Any)
class datahold.HoldDict(*args: Any, **kwargs: Any)
data: frozendict
This property is implemented with the equivalent to the following code:
@property
def data(self: Self) -> dict:
    return dict(self._data)

@data.setter
def data(self: Self, value: Any) -> None:
    self._data = frozendict(value)
class datahold.HoldList(*args: Any, **kwargs: Any)
data: tuple
This property is implemented with the equivalent to the following code:
@property
def data(self: Self) -> tuple:
    return self._data

@data.setter
def data(self: Self, value: Any) -> None:
    self._data = tuple(value)
class datahold.HoldSet(*args: Any, **kwargs: Any)
data: frozenset
This property is implemented with the equivalent to the following code:
@property
def data(self: Self) -> frozenset:
    return self._data

@data.setter
def data(self: Self, value: Any) -> None:
    self._data = frozenset(value)
class datahold.OkayABC(*args: Any, **kwargs: Any)

A common ABC for OkayList, OkayDict, and OkaySet. Child of Scaevola and HoldABC . It implements common-sense overwrites for some methods. For example:

  • All methods that cannot actually change the underlying object are now bound to _data instead of data.
  • __bool__ is implemented as bool(self._data) because neither list, dict, nor set have a __bool__ method defined.
  • The comparison operations are overwritten:
    • __eq__ returns self._data == type(self._data)(other).
    • __ne__ negates __eq__.
    • __ge__ returns type(self)(other) <= self (inherited from scaevola.Scaevola).
    • __gt__ returns not (self == other) and (self >= other).
    • __lt__ returns not (self == other) and (self <= other).
    • __le__ returns self._data <= type(self)(other)._data.

Modify __eq__ or __le__ as needed to change the behavior of the other comparison methods.

class datahold.OkayDict(data: Iterable = (), /, **kwargs: Any)

A subclass of HoldDict with common-sense implementations for further inheritance, just like OkayList for HoldList.

class datahold.OkayList(data: Iterable = ())

This class inherits from HoldList and OkayABC.

class datahold.OkaySet(data: Iterable = ())

A subclass of HoldSet with common-sense implementations for further inheritance, just like OkayList for HoldList.

class datahold.DataABC(*args: Any, **kwargs: Any)
__hash__() -> int

This magic method implements the inbuilt function hash. Its function is unhash.unhash . It always raises a TypeError.

__subclasshook__(other: type, /) -> bool
data: Any

This abstract property acts as the linchpin of all decending classes.

class datahold.DataDict[Key, Value](*args: Any, **kwargs: Any)

This class is a brute wrapper for dict. It inherits from DataABC and collections.abc.MutableMapping . Its constructor passes all arguments to the constructor of dict and the result is saved within the data property.

__contains__(key: Any, /) -> Any

This magic method implements the in operator. Internally its code is equivalent to the following:

def __contains__(self: Self, key: Any, /) -> Any:
    "True if the dictionary has the specified key, else False."
    data = dict(self.data)
    ans = data.__contains__(*args, **kwargs)
    self.data = frozendict(data)
    return ans

The imprecise annotations and docstring are due to it adhering to the underlying dict.__contains__ as closely as possible.

__delitem__(key: Any, /) -> Any

This magic method implements the deletion of items. Its inner workings are analogous to __contains__ .

__eq__(value: Any, /) -> Any

This magic method implements the == operator. Its inner workings are analogous to __contains__ .

__format__(format_spec: Any, /) -> Any

This magic method implements the inbuilt format function. Its inner workings are analogous to __contains__ .

__ge__(value: Any, /) -> Any

This magic method implements the >= operator. Its inner workings are analogous to __contains__ .

__getitem__(key: Any, /) -> Any

This magic method implements the returning of items. Its inner workings are analogous to __contains__ .

__gt__(value: Any, /) -> Any

This magic method implements the > operator. Its inner workings are analogous to __contains__ .

__hash__() -> int

This magic method implements the inbuilt function hash. Its function is unhash.unhash . It always raises a TypeError.

__ior__(value: Any, /) -> Any

This magic method implements the |= operator. Its inner workings are analogous to __contains__ .

__iter__() -> Any

This magic method implements iteration. Its inner workings are analogous to __contains__ .

__le__(value: Any, /) -> Any

This magic method implements the <= operator. Its inner workings are analogous to __contains__ .

__len__() -> Any

This magic method implements the inbuilt len function. Its inner workings are analogous to __contains__ .

__lt__(value: Any, /) -> Any

This magic method implements the < operator. Its inner workings are analogous to __contains__ .

__or__(value: Any, /) -> Any

This magic method implements the | operator. Its inner workings are analogous to __contains__ .

__repr__() -> Any

This magic method implements representation. Its inner workings are analogous to __contains__ .

__reversed__() -> Any

This magic method implements the inbuilt reversed function. Its inner workings are analogous to __contains__ .

__ror__(value: Any, /) -> Any

This magic method implements the | operator from the right side if the left operand does not have it implemented. Its inner workings are analogous to __contains__ .

__setitem__(key: Any, value: Any, /) -> Any

This magic method implements the setting of items. Its inner workings are analogous to __contains__ .

__str__() -> Any

This magic method implements the explicit conversion into a string. Its inner workings are analogous to __contains__ .

__subclasshook__(other: type, /) -> bool

This classmethod is inherited directly from DataABC .

clear() -> Any

This method deletes of all items. Its inner workings are analogous to __contains__ .

copy() -> Any

This method implements dublication. Its inner workings are analogous to __contains__ . Remember that because of that a dict is returned.

get(key: Any, default: Any = None, /) -> Any

This method implements getting an item with a default in case of its absence. Its inner workings are analogous to __contains__ .

items() -> Any

This method returns an iterator over the items. Its inner workings are analogous to __contains__ .

keys() -> Any

This method returns an iterator over the keys. Its inner workings are analogous to __contains__ .

popitem() -> Any

This method deletes and returns the last item. Its inner workings are analogous to __contains__ .

setdefault(key: Any, default: Any = None, /) -> Any

This method ensures the presence of a key. Its inner workings are analogous to __contains__ .

update(*args: Any, **kwargs: Any) -> Any

This method updates the data. Its inner workings are analogous to __contains__ .

values() -> Any

This method returns an iterator over the values. Its inner workings are analogous to __contains__ .

class datahold.DataList[Item](*args: Any, **kwargs: Any)

This class is analogous to DataDict . It implements the magic methods __add__, __contains__, __delitem__, __eq__, __format__, __ge__, __getitem__, __gt__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __repr__, __reversed__, __rmul__, __setitem__, and __str__. The other methods implemented are append, clear, copy, count, extend, index, insert, pop, remove, reverse, and sort. It is a child of DataABC and of collections.abc.MutableSequence , thereby also inheriting their members.

class datahold.DataSet[Item](*args: Any, **kwargs: Any)

This class is analogous to DataDict . It implements the magic methods __and__, __contains__, __eq__, __format__, __ge__, __gt__, __iand__, __ior__, __isub__, __iter__, __le__, __len__, __lt__, __or__, __rand__, __repr__, __ror__, __rsub__, __rxor__, __str__, __sub__, __rmul__, __sub__, and __xor__. The other methods implemented are add, clear, copy, difference, difference_update, discard, intersection, intersection_update, isdisjoint, issubset, issuperset, pop, remove, symmetric_difference, symmetric_difference_update, union, and update. It is a child of DataABC and of collections.abc.MutableSet , thereby also inheriting their members.

class datahold.HoldABC(*args: Any, **kwargs: Any)
class datahold.HoldDict[Key, Value](*args: Any, **kwargs: Any)
data: frozendict
This property is implemented with the equivalent to the following code:
                                    @property
def data(self: Self) -> dict:
    return dict(self._data)

@data.setter
def data(self: Self, value: Any) -> None:
    self._data = frozendict(value)
class datahold.HoldList[Item](*args: Any, **kwargs: Any)
data: tuple
This property is implemented with the equivalent to the following code:
@property
def data(self: Self) -> tuple:
    return self._data

@data.setter
def data(self: Self, value: Any) -> None:
    self._data = tuple(value)
class datahold.HoldSet[Item](*args: Any, **kwargs: Any)
data: frozenset
This property is implemented with the equivalent to the following code:
@property
def data(self: Self) -> frozenset:
    return self._data

@data.setter
def data(self: Self, value: Any) -> None:
    self._data = frozenset(value)
class datahold.OkayABC(*args: Any, **kwargs: Any)

A common ABC for OkayList, OkayDict, and OkaySet. Child of Scaevola and HoldABC . It implements common-sense overwrites for some methods. For example:

  • All methods that cannot actually change the underlying object are now bound to _data instead of data.
  • __bool__ is implemented as bool(self._data) because neither list, dict, nor set have a __bool__ method defined.
  • The comparison operations are overwritten:
    • __eq__ returns self._data == type(self._data)(other).
    • __ne__ negates __eq__.
    • __ge__ returns type(self)(other) <= self (inherited from scaevola.Scaevola).
    • __gt__ returns not (self == other) and (self >= other).
    • __lt__ returns not (self == other) and (self <= other).
    • __le__ returns self._data <= type(self)(other)._data.

Modify __eq__ or __le__ as needed to change the behavior of the other comparison methods.

class datahold.OkayDict[Key, Value](data: Iterable = (), /, **kwargs: Any)

A subclass of HoldDict with common-sense implementations for further inheritance, just like OkayList for HoldList.

class datahold.OkayList[Item](data: Iterable = ())

This class inherits from HoldList and OkayABC.

class datahold.OkaySet[Item](data: Iterable = ())

A subclass of HoldSet with common-sense implementations for further inheritance, just like OkayList for HoldList.

class datahold.BaseDataDict[Key, Value](*args: Any, **kwargs: Any)

This abstract base class inherits from BaseDataObject . It implements all methods and classmethods of dict that cannot change the underlying instance (and that are not already present in object).

__slots__ = ()
__contains__(key: Any, /) -> Any

See BaseDataDict and __format__ for more information.

__eq__(value: Any, /) -> Any

See BaseDataDict and __format__ for more information.

__format__(format_spec: Any, /) -> Any

This magic method implements the builtin format function. It works as follows:

def __format__(self: Self, format_spec: Any, /) -> Any
    "Default object formatter."
    return dict[Key, Value](self.data).__format__(*args, **kwargs)

Docsting and signature are somewhat imprecise because they mimic the original method of dict.

__ge__(value: Any, /) -> Any

See BaseDataDict and __format__ for more information.

__getitem__(*args: Any, **kwargs: Any) -> Any

See BaseDataDict and __format__ for more information.

__gt__(value: Any, /) -> Any

See BaseDataDict and __format__ for more information.

__iter__() -> Any

See BaseDataDict and __format__ for more information.

__le__(value: Any, /) -> Any

See BaseDataDict and __format__ for more information.

__len__() -> Any

See BaseDataDict and __format__ for more information.

__lt__(value: Any, /) -> Any

See BaseDataDict and __format__ for more information.

__or__(value: Any, /) -> Any

See BaseDataDict and __format__ for more information.

__repr__() -> Any

See BaseDataDict and __format__ for more information.

__reversed__() -> Any

See BaseDataDict and __format__ for more information.

__ror__(value: Any, /) -> Any

See BaseDataDict and __format__ for more information.

__str__() -> Any

See BaseDataDict and __format__ for more information.

data: frozendict[Key, Value]

This abstract property is inherited from BaseDataObject and reannotated.

fromkeys(iterable: Any, value: Any = None, /) -> Any

fromkeys is the only classmethod of dict and therefore also of BaseDataDict . It works as follows:

@classmethod
def fromkeys(cls: type[Self], iterable: Any, value: Any = None, /) -> Any:
    "Create a new dictionary with keys from iterable and values set to value."
    return cls[Key, Value](dict[Key, Value].fromkeys(iterable, value))

See BaseDataDict and __format__ for more information.

get(key: Any, default: Any = None, /) -> Any

See BaseDataDict and __format__ for more information.

keys() -> Any

See BaseDataDict and __format__ for more information.

items() -> Any

See BaseDataDict and __format__ for more information.

values() -> Any

See BaseDataDict and __format__ for more information.

class datahold.BaseDataList[Item](data: Iterable, /)

This abstract base class inherits from BaseDataObject . It works analogously to BaseDataDict . It data property is annotated as tuple[Item, ...]. It implements the methods __add__, __contains__, __eq__, __format__, __ge__, __getitem__, __gt__, __iter__, __le__, __len__, __lt__, __mul__, __repr__, __reversed__, __rmul__, __str__, count, and index accordingly. It has no classmethod to implement.

class datahold.BaseDataObject(*args: Any, **kwargs: Any)

This abstract base class is the ancestor of all other classes in datahold.core .

data: Any
This property is abstract.
class datahold.BaseDataSet(*args: Any, **kwargs: Any)

This abstract base class inherits from BaseDataObject . It works analogously to BaseDataDict . It implements the methods __and__, __contains__, __eq__, __format__, __ge__, __gt__, __iter__, __le__, __len__, __lt__, __or__, __rand__, __repr__, __ror__, __rsub__, __rxor__, __str__, __sub__, __xor__, difference, intersection, isdisjoint, issubset, issuperset, symmetric_difference, and union accordingly. It has no classmethod to implement.

class datahold.BaseHoldDict[Key, Value](*args: Any, **kwargs: Any)

This abstract class inherits from BaseHoldObject and from BaseDataDict[Key, Value] .

__slots__ = ()

The slot layout of the class is dictated by BaseHoldObject .

data: dict[Key, Value]

This abstract property is inherited from both parent classes.

class datahold.BaseHoldList(*args: Any, **kwargs: Any)

This abstract class inherits from BaseHoldObject and from BaseDataList[Item] .

__slots__ = ()

The slot layout of the class is dictated by BaseHoldObject .

data: tuple[Item, ...]

This abstract property is inherited from both parent classes.

class datahold.BaseHoldObject(*args: Any, **kwargs: Any)

This abstract class inherits from BaseDataObject . It sets __slots__ to ("_data",).

class datahold.BaseHoldSet(*args: Any, **kwargs: Any)

This abstract class inherits from BaseHoldObject and from BaseDataSet[Item] .

__slots__ = ()

The slot layout of the class is dictated by BaseHoldObject .

data: frozenset[Item]

This abstract property is inherited from both parent classes.

class datahold.DataDict[Key, Value](*args: Any, **kwargs: Any)

This abstract base class inherits from DataObject , BaseDataDict[Key, Value] , and collections.abc.MutableMapping[Key, Value]. It implements all methods and classmethods of dict that can change the underlying instance (and that are not already present in object). The implementation of __format__ works like this:

def __format__(self: Self, format_spec: Any, /) -> Any
    "Default object formatter."
    return dict[Key, Value](self.data).__contains__(*args, **kwargs)

Docsting and signature are somewhat imprecise because they mimic the original method of dict. The other methods - __contains__, __eq__, __ge__, __getitem__, __gt__, __iter__, __le__, __len__, __lt__, __or__, __repr__, __reversed__, __ror__, __str__, get, items, keys, and values - work analogously. fromkeys - the only classmethod - works as follows:

@classmethod
def fromkeys(cls: type, iterable: Any, value: Any = None, /) -> Any:
    "Create a new dictionary with keys from iterable and values set to value."
    return dict[Key, Value].fromkeys(*args, **kwargs)
class datahold.DataList(*args: Any, **kwargs: Any)
class datahold.DataObject(*args: Any, **kwargs: Any)
copy() -> Self
This method returns type(self)(self.data).
class datahold.DataSet(*args: Any, **kwargs: Any)
class datahold.FrozenDataDict(*args: Any, **kwargs: Any)
class datahold.FrozenDataList(*args: Any, **kwargs: Any)
class datahold.FrozenDataObject(*args: Any, **kwargs: Any)
class datahold.FrozenDataSet(*args: Any, **kwargs: Any)
class datahold.FrozenHoldDict(*args: Any, **kwargs: Any)
class datahold.FrozenHoldList(*args: Any, **kwargs: Any)
class datahold.FrozenHoldObject(*args: Any, **kwargs: Any)
class datahold.FrozenHoldSet(*args: Any, **kwargs: Any)
class datahold.HoldDict(data: Iterable = (), **kwargs: Any)
class datahold.HoldList(*args: Any, **kwargs: Any)
class datahold.HoldObject(*args: Any, **kwargs: Any)
class datahold.HoldSet(*args: Any, **kwargs: Any)
class datahold.OkayDict(data: Iterable = (), **kwargs: Any)
class datahold.OkayList(*args: Any, **kwargs: Any)
class datahold.OkayObject(*args: Any, **kwargs: Any)
class datahold.OkaySet(*args: Any, **kwargs: Any)
Testing
License
Impressum