当前位置: 首页>>代码示例>>Python>>正文


Python UserDict.__setitem__方法代码示例

本文整理汇总了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 
开发者ID:coin3d,项目名称:pivy,代码行数:26,代码来源:Environment.py

示例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) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:6,代码来源:utilities.py

示例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) 
开发者ID:coin3d,项目名称:pivy,代码行数:5,代码来源:Environment.py

示例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) 
开发者ID:coin3d,项目名称:pivy,代码行数:17,代码来源:Environment.py

示例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) 
开发者ID:coin3d,项目名称:pivy,代码行数:5,代码来源:Util.py

示例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 
开发者ID:coin3d,项目名称:pivy,代码行数:5,代码来源:Util.py

示例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) 
开发者ID:MyRobotLab,项目名称:pyrobotlab,代码行数:9,代码来源:feedparser.py

示例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) 
开发者ID:MyRobotLab,项目名称:pyrobotlab,代码行数:7,代码来源:feedparser.py

示例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) 
开发者ID:mirskytech,项目名称:ansible-role-manager,代码行数:5,代码来源:odict.py

示例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) 
开发者ID:gltn,项目名称:stdm,代码行数:8,代码来源:utils.py

示例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) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:7,代码来源:util.py


注:本文中的UserDict.UserDict.__setitem__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。