當前位置: 首頁>>代碼示例>>Python>>正文


Python OrderedDict.__setattr__方法代碼示例

本文整理匯總了Python中collections.OrderedDict.__setattr__方法的典型用法代碼示例。如果您正苦於以下問題:Python OrderedDict.__setattr__方法的具體用法?Python OrderedDict.__setattr__怎麽用?Python OrderedDict.__setattr__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在collections.OrderedDict的用法示例。


在下文中一共展示了OrderedDict.__setattr__方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __setattr__

# 需要導入模塊: from collections import OrderedDict [as 別名]
# 或者: from collections.OrderedDict import __setattr__ [as 別名]
def __setattr__(self, name, value):
        """
        Implemented so that accesses to ``sequence`` raise a warning and are
        diverted to the new ``setkeys`` method.
        """
        if name == 'sequence':
            warnings.warn('Use of the sequence attribute is deprecated.'
                ' Use the keys method instead.', DeprecationWarning)
            # NOTE: doesn't return anything
            self.setkeys(value)
        else:
            # FIXME: do we want to allow arbitrary setting of attributes?
            #   Or do we want to manage it?
            object.__setattr__(self, name, value) 
開發者ID:vulscanteam,項目名稱:vulscan,代碼行數:16,代碼來源:odict.py

示例2: __setattr__

# 需要導入模塊: from collections import OrderedDict [as 別名]
# 或者: from collections.OrderedDict import __setattr__ [as 別名]
def __setattr__(self, key, val):
        if key in Dict.__reserved_names__:
            # Either let OrderedDict do its work, or disallow
            if key not in Dict.__pure_names__:  # pragma: no cover
                return _dict.__setattr__(self, key, val)
            else:
                raise AttributeError('Reserved name, this key can only ' +
                                     'be set via ``d[%r] = X``' % key)
        else:
            # if isinstance(val, dict): val = Dict(val) -> no, makes a copy!
            self[key] = val 
開發者ID:flexxui,項目名稱:flexx,代碼行數:13,代碼來源:_dict.py

示例3: __setattr__

# 需要導入模塊: from collections import OrderedDict [as 別名]
# 或者: from collections.OrderedDict import __setattr__ [as 別名]
def __setattr__(self, key, val):
        if key in Dict.__reserved_names__:
            # Either let OrderedDict do its work, or disallow
            if key not in Dict.__pure_names__:
                return _dict.__setattr__(self, key, val)
            else:
                raise AttributeError('Reserved name, this key can only ' +
                                     'be set via ``d[%r] = X``' % key)
        else:
            # if isinstance(val, dict): val = Dict(val) -> no, makes a copy!
            self[key] = val 
開發者ID:domlysz,項目名稱:BlenderGIS,代碼行數:13,代碼來源:util.py


注:本文中的collections.OrderedDict.__setattr__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。