本文整理匯總了Python中jsb.utils.lazydict.LazyDict.__contains__方法的典型用法代碼示例。如果您正苦於以下問題:Python LazyDict.__contains__方法的具體用法?Python LazyDict.__contains__怎麽用?Python LazyDict.__contains__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jsb.utils.lazydict.LazyDict
的用法示例。
在下文中一共展示了LazyDict.__contains__方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Pdod
# 需要導入模塊: from jsb.utils.lazydict import LazyDict [as 別名]
# 或者: from jsb.utils.lazydict.LazyDict import __contains__ [as 別名]
class Pdod(Persist):
""" pickled dicts of dicts """
def __init__(self, filename):
Persist.__init__(self, filename)
if not self.data: self.data = LazyDict()
def __getitem__(self, name):
""" return item with name """
if self.data.has_key(name): return self.data[name]
def save(self):
Persist.save(self)
def __delitem__(self, name):
""" delete name item """
if self.data.has_key(name): return self.data.__delitem__(name)
def __setitem__(self, name, item):
""" set name item """
self.data[name] = item
def __contains__(self, name):
return self.data.__contains__(name)
def setdefault(self, name, default):
""" set default of name """
return self.data.setdefault(name, default)
def has_key(self, name):
""" has name key """
return self.data.has_key(name)
def has_key2(self, name1, najsb):
""" has [name1][najsb] key """
if self.data.has_key(name1): return self.data[name1].has_key(najsb)
def get(self, name1, najsb):
""" get data[name1][najsb] """
try:
result = self.data[name1][najsb]
return result
except KeyError: pass
def set(self, name1, najsb, item):
""" set name, najsb item """
if not self.data.has_key(name1): self.data[name1] = {}
self.data[name1][najsb] = item