具有可变设置接口和方向可变映射方面的一对一映射。
otomap的Python项目详细描述
otmap提供了一对一的映射抽象,呈现为 (左,右)项的可变设置接口。一个otmap实例 具有左和右方面属性,它们都提供可变映射 具有互补方向性的界面。
示例
>>> from otomap import OTOMap >>> oto = OTOMap() >>> oto.add(('foo', 'bar')) >>> ('foo', 'bar') in oto True >>> list(oto) [('foo', 'bar')] >>> oto.left['foo'] 'bar' >>> oto.right['bar'] 'foo' >>> oto.left['X'] = 'bar' >>> list(oto) [('X', 'bar')] >>> del oto.right['bar'] >>> oto.left.items() []