A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-June/153995.html below:

[Python-Dev] PySequence_Check but no __len__

[Python-Dev] PySequence_Check but no __len__ [Python-Dev] PySequence_Check but no __len__Terry Reedy tjreedy at udel.edu
Fri Jun 22 15:07:32 EDT 2018
On 6/22/2018 7:17 AM, Christian Tismer wrote:

> 
> My 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.html

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-classes

says that a Sequence has both __getitem__ and __len__.

I am surprised that a C-API function calls something a 'sequence' 
without it having __len__.

-- 
Terry Jan Reedy

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4