本文整理汇总了Python中UserDict.UserDict.__setitem__方法的典型用法代码示例。如果您正苦于以下问题:Python UserDict.__setitem__方法的具体用法?Python UserDict.__setitem__怎么用?Python UserDict.__setitem__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserDict.UserDict
的用法示例。
在下文中一共展示了UserDict.__setitem__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __setitem__
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def __setitem__(self, key, value):
# This is heavily used. This implementation is the best we have
# according to the timings in bench/env.__setitem__.py.
#
# The "key in self._special_set_keys" test here seems to perform
# pretty well for the number of keys we have. A hard-coded
# list works a little better in Python 2.5, but that has the
# disadvantage of maybe getting out of sync if we ever add more
# variable names. Using self._special_set.has_key() works a
# little better in Python 2.4, but is worse then this test.
# So right now it seems like a good trade-off, but feel free to
# revisit this with bench/env.__setitem__.py as needed (and
# as newer versions of Python come out).
if key in self._special_set_keys:
self._special_set[key](self, key, value)
else:
# If we already have the entry, then it's obviously a valid
# key and we don't need to check. If we do check, using a
# global, pre-compiled regular expression directly is more
# efficient than calling another function or a method.
if key not in self._dict \
and not _is_valid_var.match(key):
raise SCons.Errors.UserError("Illegal construction variable `%s'" % key)
self._dict[key] = value
示例2: __setitem__
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def __setitem__(self, key, item):
UserDict.__setitem__(self, key, item)
if key not in self._keys:
self._keys.append(key)
示例3: update
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def update(self, dict):
for i, v in dict.items():
self.__setitem__(i, v)
示例4: Replace
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def Replace(self, **kw):
"""Replace existing construction variables in an Environment
with new construction variables and/or values.
"""
try:
kwbd = kw['BUILDERS']
except KeyError:
pass
else:
kwbd = semi_deepcopy(kwbd)
del kw['BUILDERS']
self.__setitem__('BUILDERS', kwbd)
kw = copy_non_reserved_keywords(kw)
self._update(semi_deepcopy(kw))
self.scanner_map_delete(kw)
示例5: update
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def update(self, dict):
for (key, val) in dict.items():
self.__setitem__(key, val)
示例6: __setitem__
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def __setitem__(self, i, item):
UserList.__setitem__(self, i, item)
self.unique = False
示例7: __setitem__
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def __setitem__(self, key, value):
for k in self.keymap.keys():
if key == k:
key = self.keymap[k]
if type(key) == types.ListType:
key = key[0]
return UserDict.__setitem__(self, key, value)
示例8: __setattr__
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def __setattr__(self, key, value):
if key.startswith('_') or key == 'data':
self.__dict__[key] = value
else:
return self.__setitem__(key, value)
示例9: __setitem__
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def __setitem__(self, key, item):
UserDict.__setitem__(self, key, item)
if key not in self._keys: self._keys.append(key)
示例10: __setitem__
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def __setitem__(self,k,v):
try:
k = k.lower()
except:
pass
_UserDict.__setitem__(self,k,v)
示例11: __setitem__
# 需要导入模块: from UserDict import UserDict [as 别名]
# 或者: from UserDict.UserDict import __setitem__ [as 别名]
def __setitem__(self, key, value):
"""Associate 'value' with 'key'. If 'key' already exists, but
in different case, it will be replaced."""
k = self._lowerOrReturn(key)
self.data[k] = (key, value)