Runtime Utility Methods

types.MappingProxyType.get()

Look up a key without raising KeyError for ordinary missing dict keys; return default when missing. Delegates to the wrapped mapping.

Formal Syntax & Structure

python syntaxpython
proxy.get(key, default=None, /)

Parameters & Attributes

NameTypeDescription
keyobjectMapping key to look up.
defaultobjectValue returned when a key is absent.

Return Value

object

The object result described above.

Working Example

Example Snippetpython
import typesp=types.MappingProxyType({"x":2})print(p.get("x"),p.get("y",9))
Python Reference