#!/usr/local/bin/python2 from abc import abstractmethod from collections import Container, Iterable, Mapping, Sequence, Sized from array import array class Array(Sized, Iterable, Container): __slots__ = () __methods = '__getitem__', '__contains__', '__iter__', '__len__' @abstractmethod def __getitem__(self, key): raise KeyError def __contains__(self, value): return any(v == value for v in self) @classmethod def __subclasshook__(cls, C): if cls is Array and all(hasattr(C, method) for method in cls.__methods): return True return NotImplemented