MCPcopy Create free account
hub / github.com/pybind/pybind11 / BareMappingLike

Class BareMappingLike

tests/test_stl.py:649–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

647
648 # Implements the Mapping protocol without explicitly inheriting from collections.abc.Mapping.
649 class BareMappingLike:
650 def __init__(self, **kwargs):
651 self.data = dict(kwargs)
652
653 def __len__(self):
654 return len(self.data)
655
656 def __getitem__(self, key):
657 return self.data[key]
658
659 def __iter__(self):
660 yield from self.data
661
662 # Implements the Mapping protocol by reusing BareMappingLike's implementation.
663 # Additionally, inherits from collections.abc.Mapping.

Callers 1

Calls

no outgoing calls

Tested by 1