On this page
  1. dict
  2. Import & Availability
  3. Overview & Signature
  4. Common Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

dict

Prev: delattr | Up: __builtins__ | Next: dir
Rel: bool, int, float, complex, str
Ref: docs.python.org — dict
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import dict

Overview & Signature

dict() -> new empty dictionary

dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via:

Common Methods & Attributes

Usage

d = dict(a=1, b=2) | {"c": 3}
assert list(d.keys()) == ["a", "b", "c"]
assert d.get("missing", 0) == 0

Gotchas

REPL Inspect

help(dict)

Linked from

Related notes