On 22.06.2018 22:07, Terry Reedy wrote:
A practical sequence check is checking for __iter__ . An iterator doesn't necessarily have a defined length -- e.g. a stream or a generator.On 6/22/2018 7:17 AM, Christian Tismer wrote:It says that plainly: "The built-in function len() returns the number of items of a sequence. " https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classesMy problem is to find out how to deal with a class which has __getitem__ but no __len__. The documentation suggests that the length of a sequence can always be obtained by len(). https://docs.python.org/3/reference/datamodel.htmlsays that a Sequence has both __getitem__ and __len__.I am surprised that a C-API function calls something a 'sequence' without it having __len__.
-- Regards, Ivan _______________________________________________ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com