I've read in the abc python module docs that a Sequence is something that implements the following: __getitem__, __len__, __contains__, __iter__, __reversed__, index, and count.
Yet, when I run the following example it yields false:
from collections import abc
class Sequence():
def __getitem__(self):
pass
def __len__(self):
pass
def index(self):
pass
def count(self):
pass
def __contains__(self):
pass
def __iter__(self):
pass
def __reversed__(self):
pass
print(isinstance(Sequence(), abc.Sequence)) # False
When I was doing similar stuff for abc.Collection or abc.Reversed to play around I got the results I expected, for example I created a dummy class that implements __contains__, __iter__, __len__ and it was in fact detected correctly as an instance of abc.Collection.
Do you have any idea what's wrong with Sequence?
EDIT 1:
from collections import abc
class CustomIterable:
def __iter__(self):
pass
print(isinstance(CustomIterable(), abc.Iterable)) # True
even though my custom iterable is not from abc it still is recognized as Iterable because it implements __iter__ special method.