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

types.MappingProxyType

Prev: types.LambdaType | Up: types | Next: types.MemberDescriptorType
Rel: types.AsyncGeneratorType, types.BuiltinFunctionType, types.BuiltinMethodType, types.CapsuleType
Ref: docs.python.org — types.MappingProxyType
Tags: #public #python3 #stdlib #types


Import

import types
from types import MappingProxyType

Signature & Overview

types.MappingProxyType(mapping)

Read-only proxy of a mapping.

Methods & Attributes

Usage

import types

backing = {'a': 1, 'b': 2}
ro = types.MappingProxyType(backing)
assert ro['a'] == 1
try:
    ro['a'] = 9
except TypeError:
    assert True

Gotchas

REPL Inspect

from types import MappingProxyType
help(MappingProxyType)

Linked from

Related notes