本文整理匯總了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