本文整理汇总了Python中org.python.core.PyStringMap方法的典型用法代码示例。如果您正苦于以下问题:Python core.PyStringMap方法的具体用法?Python core.PyStringMap怎么用?Python core.PyStringMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.python.core
的用法示例。
在下文中一共展示了core.PyStringMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from org.python import core [as 别名]
# 或者: from org.python.core import PyStringMap [as 别名]
def __init__(self, value):
self.value = value
# Jython has PyStringMap; it's a dict subclass with string keys
示例2: test_all
# 需要导入模块: from org.python import core [as 别名]
# 或者: from org.python.core import PyStringMap [as 别名]
def test_all(self):
d = PyStringMap()
# Test __setitem__
d["one"] = 1
# Test __getitem__
self.assertEqual(d["one"], 1)
self.assertRaises(KeyError, d.__getitem__, "two")
# Test __delitem__
del d["one"]
self.assertRaises(KeyError, d.__delitem__, "one")
# Test clear
d.update(self._reference())
d.clear()
self.assertEqual(d, {})
# Test copy()
d.update(self._reference())
da = d.copy()
self.assertEqual(d, da)
# Test keys, items, values
r = self._reference()
d.update(self._reference())
for k in d.keys():
self.failUnless(k in r.keys())
for i in d.items():
self.failUnless(i in r.items())
for v in d.values():
self.failUnless(v in r.values())
# Test has_key and "in".
for i in r.keys():
self.assert_(d.has_key(i))
self.assert_(i in d)
# Test unhashability
self.assertRaises(TypeError, hash, d)
示例3: __init__
# 需要导入模块: from org.python import core [as 别名]
# 或者: from org.python.core import PyStringMap [as 别名]
def __init__(self, value):
self.value = value
# Jython has PyStringMap; it's a dict subclass with string keys