本文整理匯總了Python中UserDict.DictMixin.values方法的典型用法代碼示例。如果您正苦於以下問題:Python DictMixin.values方法的具體用法?Python DictMixin.values怎麽用?Python DictMixin.values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserDict.DictMixin
的用法示例。
在下文中一共展示了DictMixin.values方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: read
# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import values [as 別名]
def read(self, *files, **params):
""" Read and parse INI files.
:param *files: Files for reading
:param **params: Params for parsing
Set `update=False` for prevent values redefinition.
"""
for f in files:
try:
with io.open(f, encoding='utf-8') as ff:
NS_LOGGER.info('Read from `{0}`'.format(ff.name))
self.parse(ff.read(), **params)
except (IOError, TypeError, SyntaxError, io.UnsupportedOperation):
if not self.silent_read:
NS_LOGGER.error('Reading error `{0}`'.format(ff.name))
raise
示例2: __delitem__
# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import values [as 別名]
def __delitem__(self, elem):
'''Like dict.__delitem__() but does not raise KeyError for
missing values.'''
if elem in self:
dict.__delitem__(self, elem)
示例3: kvquery
# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import values [as 別名]
def kvquery(root, **kwargs):
'''kvquery provides a convinient way of finding widgets in an
application that uses the kv style language.
example:
lets say you have a .kv file with the following Rule:
<MovieWidget>:
BoxLayout:
Video:
kvid: 'video'
Label:
text: root.movie_title
Label:
text: root.movie_description
in your python code, you may want to get the reference to
Video widget nested inside the widget you have a handle to.
# video will be the first node that jas a 'kvid' property == 'video'
video = kvquery(movie, kvid='video').next()
#lets get all teh labels in a list
labels = list(kvquery(movie, __class__=Label))
:Parameters:
`root`: root of the tree to queried
this node and all decendants will be iterated by the
returned generator.
`**kwargs`: **kwargs, key/value pairs
The keys corrosponf to porperty names, and values to the
property values of the widget nodes being queried. If a node
has at least one attr such that (gettattr(node, key) == value)
is true; it will be included in the iteration.
'''
def _query(w):
'''iternal query function / predicate for tree query
'''
for k, v in kwargs.iteritems():
if (v == getattr(w, k, None)):
return True
return filter_tree(root, _query)