kwcoco.util.dict_like module

class kwcoco.util.dict_like.DictLike[source]

Bases: NiceRepr

An inherited class must specify the getitem, setitem, and

keys methods.

A class is dictionary like if it has:

__iter__, __len__, __contains__, __getitem__, items, keys, values, get,

and if it should be writable it should have: __delitem__, __setitem__, update,

And perhaps: copy,

__iter__, __len__, __contains__, __getitem__, items, keys, values, get,

and if it should be writable it should have: __delitem__, __setitem__, update,

And perhaps: copy,

getitem(key)[source]
Parameters

key (Any) – a key

Returns

a value

Return type

Any

setitem(key, value)[source]
Parameters
  • key (Any)

  • value (Any)

delitem(key)[source]
Parameters

key (Any)

keys()[source]
Yields

Any – a key

items()[source]
Yields

Tuple[Any, Any] – a key value pair

values()[source]
Yields

Any – a value

copy()[source]
Return type

Dict

to_dict()[source]
Return type

Dict

asdict()
Return type

Dict

update(other)[source]
get(key, default=None)[source]
Parameters
  • key (Any)

  • default (Any)

Return type

Any