- class dictobj(*args, **kwargs)[source]#
Lightweight class to create an object that can also act like a dictionary.
obj = sc.dictobj() obj.a = 5 obj['b'] = 10 print(obj.items())
For a more powerful alternative, see
dictobjis halfway between a dict and an object, it can’t be automatically converted to a JSON (but will fail silently). Use
to_json()instead.New in version 1.3.0.New in version 1.3.1: inherit from dictNew in version 2.0.0: allow positional argumentsNew in version 3.0.0: “fromkeys” now a class method;
Export the dictobj to JSON (NB: regular
json.dumps()does not work)
- pop(k[, d]) v, remove specified key and return the corresponding value. [source]#
If key is not found, default is returned if given, otherwise KeyError is raised
- popitem(*args, **kwargs)[source]#
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(*args, **kwargs)[source]#
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F. [source]#
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]