本文整理汇总了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