python类__setitem__()的实例源码

Environment.py 文件源码 项目:StatisKit 作者: StatisKit 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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 than 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
Environment.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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 than 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
Environment.py 文件源码 项目:coretools 作者: iotile 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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 than 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
__init__.py 文件源码 项目:vivisect-py3 作者: bat-serjo 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, initdict=None):
        UserDict.__init__(self)
        if initdict == None:
            return

        for key, val in list(initdict.items()):
            self.__setitem__(self, key, val)
__init__.py 文件源码 项目:vivisect-py3 作者: bat-serjo 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __setitem__(self, key, item):
        UserDict.__setitem__(self, key, item)
        UserDict.__setitem__(self, item, key)
Environment.py 文件源码 项目:StatisKit 作者: StatisKit 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __setitem__(self, item, val):
        try:
            method = getattr(self.env, item).method
        except AttributeError:
            pass
        else:
            self.env.RemoveMethod(method)
        UserDict.__setitem__(self, item, val)
        BuilderWrapper(self.env, val, item)
Environment.py 文件源码 项目:StatisKit 作者: StatisKit 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def update(self, dict):
        for i, v in dict.items():
            self.__setitem__(i, v)
Environment.py 文件源码 项目:StatisKit 作者: StatisKit 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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 = BuilderDict(kwbd,self)
            del kw['BUILDERS']
            self.__setitem__('BUILDERS', kwbd)
        kw = copy_non_reserved_keywords(kw)
        self._update(semi_deepcopy(kw))
        self.scanner_map_delete(kw)
Environment.py 文件源码 项目:StatisKit 作者: StatisKit 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        if not is_valid_construction_var(key):
            raise SCons.Errors.UserError("Illegal construction variable `%s'" % key)
        self.__dict__['overrides'][key] = value
Util.py 文件源码 项目:StatisKit 作者: StatisKit 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def update(self, dict):
        for (key, val) in dict.items():
            self.__setitem__(key, val)
Util.py 文件源码 项目:StatisKit 作者: StatisKit 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __setitem__(self, i, item):
        UserList.__setitem__(self, i, item)
        self.unique = False
Util.py 文件源码 项目:StatisKit 作者: StatisKit 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __setitem__(self, i, v):
        return self
utils.py 文件源码 项目:django-twilio-tfa 作者: rtindru 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        data = base64.b64encode(pickle.dumps(value)).decode('ascii')
        return UserDict.__setitem__(self, key, data)
Environment.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __setitem__(self, item, val):
        try:
            method = getattr(self.env, item).method
        except AttributeError:
            pass
        else:
            self.env.RemoveMethod(method)
        UserDict.__setitem__(self, item, val)
        BuilderWrapper(self.env, val, item)
Environment.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def update(self, dict):
        for i, v in dict.items():
            self.__setitem__(i, v)
Environment.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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 = BuilderDict(kwbd,self)
            del kw['BUILDERS']
            self.__setitem__('BUILDERS', kwbd)
        kw = copy_non_reserved_keywords(kw)
        self._update(semi_deepcopy(kw))
        self.scanner_map_delete(kw)
Environment.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        if not is_valid_construction_var(key):
            raise SCons.Errors.UserError("Illegal construction variable `%s'" % key)
        self.__dict__['overrides'][key] = value
Util.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def update(self, dict):
        for (key, val) in dict.items():
            self.__setitem__(key, val)
Util.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __setitem__(self, i, item):
        UserList.__setitem__(self, i, item)
        self.unique = False
Util.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __setitem__(self, i, v):
        return self
Environment.py 文件源码 项目:coretools 作者: iotile 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __setitem__(self, item, val):
        try:
            method = getattr(self.env, item).method
        except AttributeError:
            pass
        else:
            self.env.RemoveMethod(method)
        UserDict.__setitem__(self, item, val)
        BuilderWrapper(self.env, val, item)
Environment.py 文件源码 项目:coretools 作者: iotile 项目源码 文件源码 阅读 55 收藏 0 点赞 0 评论 0
def update(self, dict):
        for i, v in dict.items():
            self.__setitem__(i, v)
Environment.py 文件源码 项目:coretools 作者: iotile 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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 = BuilderDict(kwbd,self)
            del kw['BUILDERS']
            self.__setitem__('BUILDERS', kwbd)
        kw = copy_non_reserved_keywords(kw)
        self._update(semi_deepcopy(kw))
        self.scanner_map_delete(kw)
Environment.py 文件源码 项目:coretools 作者: iotile 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        if not is_valid_construction_var(key):
            raise SCons.Errors.UserError("Illegal construction variable `%s'" % key)
        self.__dict__['overrides'][key] = value
Util.py 文件源码 项目:coretools 作者: iotile 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def update(self, dict):
        for (key, val) in dict.items():
            self.__setitem__(key, val)
Util.py 文件源码 项目:coretools 作者: iotile 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __setitem__(self, i, item):
        UserList.__setitem__(self, i, item)
        self.unique = False
Util.py 文件源码 项目:coretools 作者: iotile 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __setitem__(self, i, v):
        return self
utils.py 文件源码 项目:Provo-Housing-Database 作者: marcopete5 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        data = base64.b64encode(pickle.dumps(value)).decode('ascii')
        return UserDict.__setitem__(self, key, data)
puid_map.py 文件源码 项目:wxpy 作者: youfou 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        if self.get(key) != value:
            if key in self:
                self.del_value(self[key])
            if value in self._reversed:
                del self[self.get_key(value)]
            self._reversed[value] = key
            if PY2:
                return UserDict.__setitem__(self, key, value)
            else:
                return super(TwoWayDict, self).__setitem__(key, value)


问题


面经


文章

微信
公众号

扫码关注公众号