diff options
author | Raymond Hettinger <python@rcn.com> | 2008-02-09 01:18:42 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-02-09 01:18:42 (GMT) |
commit | c2bc0d17e83ad88b829a669cc9ee7194b9e46593 (patch) | |
tree | 85b6f245346fe46f9408110618818ec4e7a30425 /Lib | |
parent | 7e33663ec439c603b1f23a8ebe255feed684c19f (diff) | |
download | cpython-c2bc0d17e83ad88b829a669cc9ee7194b9e46593.zip cpython-c2bc0d17e83ad88b829a669cc9ee7194b9e46593.tar.gz cpython-c2bc0d17e83ad88b829a669cc9ee7194b9e46593.tar.bz2 |
Make ABC containers inherit as documented.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/_abcoll.py | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index 4009ccb..6f1759b 100644 --- a/Lib/_abcoll.py +++ b/Lib/_abcoll.py @@ -56,7 +56,7 @@ class Iterable: Iterable.register(str) -class Iterator: +class Iterator(Iterable): __metaclass__ = ABCMeta @abstractmethod @@ -122,7 +122,7 @@ class Callable: ### SETS ### -class Set: +class Set(Sized, Iterable, Container): __metaclass__ = ABCMeta """A set is a finite, iterable container. @@ -135,19 +135,6 @@ class Set: then the other operations will automatically follow suit. """ - @abstractmethod - def __contains__(self, value): - return False - - @abstractmethod - def __iter__(self): - while False: - yield None - - @abstractmethod - def __len__(self): - return 0 - def __le__(self, other): if not isinstance(other, Set): return NotImplemented @@ -324,7 +311,7 @@ MutableSet.register(set) ### MAPPINGS ### -class Mapping: +class Mapping(Sized, Iterable, Container): __metaclass__ = ABCMeta @abstractmethod @@ -345,15 +332,6 @@ class Mapping: else: return True - @abstractmethod - def __len__(self): - return 0 - - @abstractmethod - def __iter__(self): - while False: - yield None - def keys(self): return KeysView(self) @@ -370,7 +348,7 @@ class Mapping: def __ne__(self, other): return not (self == other) -class MappingView: +class MappingView(Sized): __metaclass__ = ABCMeta def __init__(self, mapping): @@ -490,7 +468,7 @@ MutableMapping.register(dict) ### SEQUENCES ### -class Sequence: +class Sequence(Sized, Iterable, Container): __metaclass__ = ABCMeta """All the operations on a read-only sequence. @@ -503,10 +481,6 @@ class Sequence: def __getitem__(self, index): raise IndexError - @abstractmethod - def __len__(self): - return 0 - def __iter__(self): i = 0 try: |