Python collections.ValuesView() Examples

The following are code examples for showing how to use collections.ValuesView(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: oil   Author: oilshell   File: test_dictviews.py    (license) View Source Project 6 votes vote down vote up
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) 
Example 2
Project: python2-tracer   Author: extremecoders-re   File: test_dictviews.py    (license) View Source Project 6 votes vote down vote up
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) 
Example 3
Project: Theano-Deep-learning   Author: GeekLiB   File: nanguardmode.py    (license) View Source Project 6 votes vote down vote up
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 
Example 4
Project: xarray-simlab   Author: benbovy   File: utils.py    (BSD 3-Clause "New" or "Revised" License) View Source Project 5 votes vote down vote up
def values(self):
        "D.values() -> an object providing a view on D's values"
        return ValuesView(self) 
Example 5
Project: central   Author: viniciuschiele   File: core.py    (license) View Source Project 5 votes vote down vote up
def values(self):
        """
        Get all the values of the configuration.
        :return tuple: The values of the configuration.
        """
        return ValuesView(self) 
Example 6
Project: python-diskcache   Author: grantjenks   File: persistent.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 7
Project: python-diskcache   Author: grantjenks   File: persistent.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 8
Project: Python_Master-the-Art-of-Design-Patterns   Author: PacktPublishing   File: 6_16_dictsorted.py    (license) View Source Project 5 votes vote down vote up
def values(self):
        return ValuesView(self) 
Example 9
Project: Deploy_XXNET_Server   Author: jzp820927   File: request_environment.py    (license) View Source Project 5 votes vote down vote up
def viewvalues(self):
    return collections.ValuesView(self) 
Example 10
Project: Python-Journey-from-Novice-to-Expert   Author: PacktPublishing   File: 6_16_dictsorted.py    (license) View Source Project 5 votes vote down vote up
def values(self):
        return ValuesView(self)