CKTIS / Python
dict()
Builds a dictionary from a mapping, key-value pairs, or keyword bindings.
Version: Python 3.14; repository image, production runtime not attested
Syntax
dict()
dict(mapping_or_pairs, /, **kwargs)
dict(**kwargs)Builds a dictionary from a mapping, key-value pairs, or keyword bindings.
Later occurrences of the same key replace the value without moving the key from its first insertion position.
Construct from a mapping, an iterable of pairs, or keyword arguments. Each key must be hashable. Repeated a receives its last value 3 but keeps its first position before b, which has value 2. Keyword bindings are processed after a positional source and can override it. No arguments create an empty dictionary.
pairs = [("a", 1), ("b", 2), ("a", 3)]
assert list(dict(pairs, b=9).items()) == [("a", 3), ("b", 9)]
Examples
pairs = [("a", 1), ("b", 2), ("a", 3)]
print(list(dict(pairs).items()))
Result
[('a', 3), ('b', 2)]Construct from a mapping, an iterable of pairs, or keyword arguments. Each key must be hashable. Repeated a receives its last value 3 but keeps its first position before b, which has value 2. Keyword bindings are processed after a positional source and can override it. No arguments create an empty dictionary.