Author terry.reedy
Recipients abarry, docs@python, story645, terry.reedy
Date 2016-07-22.20:28:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The view objects *are* built-ins, but are not exposed in the __builtins__ module.  This is true of many internal types, perhaps even a majority. The function and list_iterator classes are other examples.

>>> type(lambda: 0)
<class 'function' at 0x0000000054B038B0>
>>> type(iter([]))
<class 'list_iterator' at 0x0000000054B05A60>

A few such 'hidden' classes are exposed in the types module.

"This module provides names for many of the types that are required to implement a Python interpreter. It deliberately avoids including some of the types that arise only incidentally during processing such as the listiterator type.

Typical use of these names is for isinstance() or issubclass() checks."

The function class is.


    The type of user-defined functions and functions created by lambda expressions."
The list_iterator class is not. Perhaps the rationale is that there is no reason to know whether an iterator is iterating over a list, tuple, range, set, frozenset, dict, or anything else.  They are all used the same.  On the other hand, Different view types are used a bit differently.

Types includes a generic MappingProxyType.  Perhaps you should propose adding the specific dict view types.  Or you can create them yourself.
  KeysViewType = type({}.keys())
  ValuesViewType = type({}.values())
  ItemsViewType = type({}.items())
This is the code that would be used in the module if they were added there.
Date User Action Args
2016-07-22 20:28:14terry.reedysetrecipients: + terry.reedy, docs@python, abarry, story645
2016-07-22 20:28:14terry.reedysetmessageid: <>
2016-07-22 20:28:14terry.reedylinkissue27544 messages
2016-07-22 20:28:13terry.reedycreate