Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

 

History

History
61 lines (42 loc) · 925 Bytes

File metadata and controls

61 lines (42 loc) · 925 Bytes

Native dict operations

These dict operations have fast, optimized implementations. Other dictionary operations use generic implementations that are often slower.

Construction

Construct dict from keys and values:

  • {key: value, ...}

Construct empty dict:

  • {}
  • dict()

Construct dict from another object:

  • dict(d: dict)
  • dict(x: Iterable)

Dict comprehensions:

  • {...: ... for ... in ...}
  • {...: ... for ... in ... if ...}

Operators

  • d[key]
  • value in d

Statements

  • d[key] = value
  • for key in d:

Methods

  • d.get(key)
  • d.get(key, default)
  • d.keys()
  • d.values()
  • d.items()
  • d.copy()
  • d.clear()
  • d.setdefault(key)
  • d.setdefault(key, value)
  • d1.update(d2: dict)
  • d.update(x: Iterable)

Functions

  • len(d: dict)