Python collections 模块,ValuesView() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用collections.ValuesView()

项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_abc_registry(self):
        d = dict(a=1)

        self.assertIsInstance(d.viewkeys(), collections.KeysView)
        self.assertIsInstance(d.viewkeys(), collections.MappingView)
        self.assertIsInstance(d.viewkeys(), collections.Set)
        self.assertIsInstance(d.viewkeys(), collections.Sized)
        self.assertIsInstance(d.viewkeys(), collections.Iterable)
        self.assertIsInstance(d.viewkeys(), collections.Container)

        self.assertIsInstance(d.viewvalues(), collections.ValuesView)
        self.assertIsInstance(d.viewvalues(), collections.MappingView)
        self.assertIsInstance(d.viewvalues(), collections.Sized)

        self.assertIsInstance(d.viewitems(), collections.ItemsView)
        self.assertIsInstance(d.viewitems(), collections.MappingView)
        self.assertIsInstance(d.viewitems(), collections.Set)
        self.assertIsInstance(d.viewitems(), collections.Sized)
        self.assertIsInstance(d.viewitems(), collections.Iterable)
        self.assertIsInstance(d.viewitems(), collections.Container)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_abc_registry(self):
        d = dict(a=1)

        self.assertIsInstance(d.viewkeys(), collections.KeysView)
        self.assertIsInstance(d.viewkeys(), collections.MappingView)
        self.assertIsInstance(d.viewkeys(), collections.Set)
        self.assertIsInstance(d.viewkeys(), collections.Sized)
        self.assertIsInstance(d.viewkeys(), collections.Iterable)
        self.assertIsInstance(d.viewkeys(), collections.Container)

        self.assertIsInstance(d.viewvalues(), collections.ValuesView)
        self.assertIsInstance(d.viewvalues(), collections.MappingView)
        self.assertIsInstance(d.viewvalues(), collections.Sized)

        self.assertIsInstance(d.viewitems(), collections.ItemsView)
        self.assertIsInstance(d.viewitems(), collections.MappingView)
        self.assertIsInstance(d.viewitems(), collections.Set)
        self.assertIsInstance(d.viewitems(), collections.Sized)
        self.assertIsInstance(d.viewitems(), collections.Iterable)
        self.assertIsInstance(d.viewitems(), collections.Container)
项目:Theano-Deep-learning    作者:GeekLiB    | 项目源码 | 文件源码
def flatten(l):
    """
    Turns a nested graph of lists/tuples/other objects into a list of objects.

    Parameters
    ----------
    l : list/tuple/other objects
        Might be nested.

    Returns
    -------
    object
        A flattened list of objects.

    """
    if isinstance(l, (list, tuple, collections.ValuesView)):
        rval = []
        for elem in l:
            if isinstance(elem, (list, tuple)):
                rval.extend(flatten(elem))
            else:
                rval.append(elem)
    else:
        return [l]
    return rval
项目:xarray-simlab    作者:benbovy    | 项目源码 | 文件源码
def values(self):
        "D.values() -> an object providing a view on D's values"
        return ValuesView(self)
项目:central    作者:viniciuschiele    | 项目源码 | 文件源码
def values(self):
        """
        Get all the values of the configuration.
        :return tuple: The values of the configuration.
        """
        return ValuesView(self)
项目:python-diskcache    作者:grantjenks    | 项目源码 | 文件源码
def viewvalues(self):
            """Set-like object providing a view of index values.

            >>> index = Index('/tmp/diskcache/index')
            >>> index.clear()
            >>> index.update({'a': 1, 'b': 2, 'c': 3})
            >>> values_view = index.viewvalues()
            >>> 2 in values_view
            True

            :return: values view

            """
            return ValuesView(self)
项目:python-diskcache    作者:grantjenks    | 项目源码 | 文件源码
def values(self):
            """Set-like object providing a view of index values.

            >>> index = Index('/tmp/diskcache/index')
            >>> index.clear()
            >>> index.update({'a': 1, 'b': 2, 'c': 3})
            >>> values_view = index.values()
            >>> 2 in values_view
            True

            :return: values view

            """
            return ValuesView(self)
项目:Python_Master-the-Art-of-Design-Patterns    作者:PacktPublishing    | 项目源码 | 文件源码
def values(self):
        return ValuesView(self)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def viewvalues(self):
    return collections.ValuesView(self)
项目:Python-Journey-from-Novice-to-Expert    作者:PacktPublishing    | 项目源码 | 文件源码
def values(self):
        return ValuesView(self)