Convert iterator __len__() methods to a private API.

This commit is contained in:
Raymond Hettinger 2005-09-24 21:23:05 +00:00
parent 9ceebd5445
commit 6b27cda643
16 changed files with 169 additions and 94 deletions

View file

@ -43,12 +43,22 @@ enumerate(iter('abc')).
import unittest
from test import test_support
from itertools import repeat, count
from itertools import repeat
from collections import deque
from UserList import UserList
from __builtin__ import len as _len
n = 10
def len(obj):
try:
return _len(obj)
except TypeError:
try:
return obj._length_cue()
except AttributeError:
raise TypeError
class TestInvariantWithoutMutations(unittest.TestCase):
def test_invariant(self):