Skip to content

Dictorary

Dictionary.

Dict

Bases: Object

Re-Implementation of python dictorary, compatible with Object.

Dictorary Examples

Basics:

>>> import ucdp as u
>>> data = u.Dict()
>>> data
Dict()

Add items:

>>> data['a'] = 1
>>> data['c'] = 3
>>> data['b'] = 2

Get items:

>>> data['a']
1
>>> data['d']
Traceback (most recent call last):
...
KeyError: 'd'

Iteration:

>>> tuple(data)
('a', 'c', 'b')

Keys:

>>> data.keys()
dict_keys(['a', 'c', 'b'])

Values:

>>> data.values()
dict_values([1, 3, 2])

Key-Value Pairs:

>>> data.items()
dict_items([('a', 1), ('c', 3), ('b', 2)])

keys

keys()

Return Dictionary Keys.

values

values()

Return Dictionary Value.

items

items()

Return Key-Value Pairs.

get

get(*args, **kwargs)

Retrieve Element.