]> granicus.if.org Git - python/commitdiff
SF [#463737] Add types.CallableIterType
authorTim Peters <tim.peters@gmail.com>
Tue, 25 Sep 2001 22:02:03 +0000 (22:02 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 25 Sep 2001 22:02:03 +0000 (22:02 +0000)
Rather than add umpteen new obscure internal Iter types, got rid of all of
them.  See the new comment.

Lib/types.py

index 941940531b313175ff07aff348f68ea135444f65..1bb560cb099e3a6ce9586897f2da643e3a0e9c8c 100644 (file)
@@ -6,6 +6,11 @@ from __future__ import generators
 
 import sys
 
+# Iterators in Python aren't a matter of type but of protocol.  A large
+# and changing number of builtin types implement *some* flavor of
+# iterator.  Don't check the type!  Use hasattr to check for both
+# "__iter__" and "next" attributes instead.
+
 NoneType = type(None)
 TypeType = type
 ObjectType = object
@@ -76,9 +81,6 @@ except TypeError:
 SliceType = type(slice(0))
 EllipsisType = type(Ellipsis)
 
-DictIterType = type(iter({}))
-SequenceIterType = type(iter([]))
-FunctionIterType = type(iter(lambda: 0, 0))
 DictProxyType = type(TypeType.__dict__)
 
 del sys, _f, _C, _x                     # Not for export