bdict¶
-
class
bdict
(seq=None, **kwargs)[source]¶ Bases:
UserDict
Returns a new dictionary initialized from an optional positional argument, and a possibly empty set of keyword arguments.
Each
key: value
pair is entered into the dictionary in both directions, so you can perform lookups with either the key or the value.If no positional argument is given, an empty dictionary is created.
If a positional argument is given and it is a mapping object, a dictionary is created with the same key-value pairs as the mapping object. Otherwise, the positional argument must be an iterable object. Each item in the iterable must itself be an iterable with exactly two objects. The first object of each item becomes a key in the new dictionary, and the second object the corresponding value.
If keyword arguments are given, the keyword arguments and their values are added to the dictionary created from the positional argument.
If an attempt is made to add a key or value that already exists in the dictionary a
ValueError
will be raised.Keys or values of
None
,True
andFalse
will be stored internally as"_None"
,"_True"
and"_False"
respectivelyMethods:
__contains__
(key)Return
key in self
.__delitem__
(key)Delete
self[key]
.__getitem__
(key)Return
self[key]
.__setitem__
(key, val)Set
self[key]
tovalue
.clear
()Removes all items from the
bdict
.get
(k[, default])Return the value for
k
ifk
is in the dictionary, elsedefault
.items
()Returns a set-like object providing a view on the
bdict
's items.keys
()Returns a set-like object providing a view on the
bdict
's keys.values
()Returns an object providing a view on the
bdict
's values.-
items
()[source]¶ Returns a set-like object providing a view on the
bdict
's items.- Return type
AbstractSet
[Tuple
[~KT
,~VT
]]
-