Python collections.KeysView() Examples

The following are 8 code examples of collections.KeysView(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module collections , or try the search function .
Example #1
Source File: test_dictviews.py    From ironpython2 with Apache License 2.0 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
Source File: 6_16_dictsorted.py    From Python-Journey-from-Novice-to-Expert with MIT License 5 votes vote down vote up
def keys(self):
        return KeysView(self) 
Example #3
Source File: ordereddict.py    From pyRevit with GNU General Public License v3.0 5 votes vote down vote up
def viewkeys(self):
        "Return set-like object with view of mapping keys."
        return KeysView(self) 
Example #4
Source File: __init__.py    From aws-cfn-template-flip with Apache License 2.0 5 votes vote down vote up
def has_intrinsic_functions(parameter):
    intrinsic_functions = ["Fn::Sub", "!Sub", "!GetAtt"]
    result = False
    if isinstance(parameter, (list, tuple, dict, KeysView)):
        for item in parameter:
            if item in intrinsic_functions:
                result = True
                break
    return result 
Example #5
Source File: 6_16_dictsorted.py    From Python_Master-the-Art-of-Design-Patterns with MIT License 5 votes vote down vote up
def keys(self):
        return KeysView(self) 
Example #6
Source File: request_environment.py    From python-compat-runtime with Apache License 2.0 5 votes vote down vote up
def viewkeys(self):
    return collections.KeysView(self) 
Example #7
Source File: connections.py    From async-worker with MIT License 5 votes vote down vote up
def keys(self):
        return KeysView(self) 
Example #8
Source File: _mutablemapping.py    From compas with MIT License 5 votes vote down vote up
def keys(self):
        """D.keys() => a set-like object providing a view on D's keys"""
        return stdlib_collections.KeysView(self)