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