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


Python collections.Mapping类代码示例

本文整理汇总了Python中collections.Mapping的典型用法代码示例。如果您正苦于以下问题:Python Mapping类的具体用法?Python Mapping怎么用?Python Mapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mapping类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __eq__

 def __eq__(self, other):
     if isinstance(other, (OrderedBidirectionalMapping, OrderedDict)):
         if len(self) != len(other):
             return False
         for i, j in izip(iteritems(self), iteritems(other)):
             if i != j:
                 return False
         return True
     if isinstance(other, Mapping):
         return Mapping.__eq__(self, other)
     return False
开发者ID:IuryAlves,项目名称:bidict,代码行数:11,代码来源:_ordered.py

示例2: DeprecationWarning

                DeprecationWarning(
                    "variables set in a base template "
                    "will no longer leak into the child "
                    "context in future versions.  Happened "
                    "when " + detail
                )
            )
            return base_rv
        return self_rv


# register the context as mapping if possible
try:
    from collections import Mapping

    Mapping.register(Context)
except ImportError:
    pass


class BlockReference(object):
    """One block on a template reference."""

    def __init__(self, name, context, stack, depth):
        self.name = name
        self._context = context
        self._stack = stack
        self._depth = depth

    @property
    def super(self):
开发者ID:paulfitz,项目名称:blender2haxe,代码行数:31,代码来源:runtime.py

示例3: prepare_field

 def prepare_field(self, field_name: str, values: collections.Mapping):
     return values.get(field_name)
开发者ID:deztructor,项目名称:pycor,代码行数:2,代码来源:operation.py

示例4: pmap

        >>> m1
        pmap({'a': 1, 'b': 2})

        The changes are kept in the evolver. An updated pmap can be created using the
        persistent() function on the evolver.

        >>> m2 = e.persistent()
        >>> m2
        pmap({'c': 3, 'b': 2})

        The new pmap will share data with the original pmap in the same way that would have
        been done if only using operations on the pmap.
        """
        return self._Evolver(self)

Mapping.register(PMap)
Hashable.register(PMap)


def _turbo_mapping(initial, pre_size):
    size = pre_size or (2 * len(initial)) or 8
    buckets = size * [None]

    if not isinstance(initial, Mapping):
        # Make a dictionary of the initial data if it isn't already,
        # that will save us some job further down since we can assume no
        # key collisions
        initial = dict(initial)

    for k, v in six.iteritems(initial):
        h = hash(k)
开发者ID:alx-,项目名称:pyrsistent,代码行数:31,代码来源:_pmap.py

示例5: list

        for key in list(other.keys()):
          self[key] = other[key]
      else:
        for key, value in other:
          self[key] = value
      for key, value in list(kwds.items()):
        self[key] = value

    def setdefault(self, key, default=None):
      try:
        return self[key]
      except KeyError:
        self[key] = default
      return default

  _Mapping.register(Mapping)

else:
  # In Python 3 we can just use MutableMapping directly, because it defines
  # __slots__.
  from collections import MutableMapping


class BaseContainer(object):

  """Base container class."""

  # Minimizes memory usage and disallows assignment to other attributes.
  __slots__ = ['_message_listener', '_values']

  def __init__(self, message_listener):
开发者ID:dukakisxyz,项目名称:wifiportal21-map,代码行数:31,代码来源:containers.py

示例6: __iter__

        return 0

    def __iter__(self):
        return ()

    def __getitem__(self, key):
        raise KeyError(key)

    def __nonzero__(self):
        return False
    __bool__ = __nonzero__

    def __enter__(self):
        return _null_context

    def __exit__(self, exc_type, exc_value, traceback):
        return False

    def get(self, name, default=None):
        return default


_null_context = NullContext()


from collections import Mapping

Mapping.register(NullContext)

del Mapping
开发者ID:edelvalle,项目名称:xoutil,代码行数:30,代码来源:context.py

示例7: values

    def values(self):
        """D.values() -> list of D's values."""
        return self._dict.values()

    def __iter__(self):
        """x.__iter__() <==> iter(x)."""
        return iter(self._dict)

    def __len__(self):
        """x.__len__() <==> len(x)."""
        return self._dict.__len__()

    def get(self, key, default=None):
        """D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None."""
        return self._dict.get(sympify(key), default)

    def __contains__(self, key):
        """D.__contains__(k) -> True if D has a key k, else False."""
        return sympify(key) in self._dict

    def __lt__(self, other):
        return sympify(self.args < other.args)

    @property
    def _sorted_args(self):
        from ..utilities import default_sort_key
        return tuple(sorted(self.args, key=default_sort_key))


Mapping.register(Dict)
开发者ID:skirpichev,项目名称:diofant,代码行数:30,代码来源:containers.py

示例8: __init__

 def __init__(self):
     """
     """
     Mapping.__init__(self)
     self.resiNumbers = defaultdict(list)
开发者ID:oserve,项目名称:PyNMR,代码行数:5,代码来源:listControllers.py


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