On 6/22/2018 7:57 PM, Greg Ewing wrote:
Terry Reedy wrote:
I am surprised that a C-API function calls something a 'sequence'
without it having __len__.
It's a bit strange that PySequence_Check exists at all.
The principle of duck typing would suggest that one
should be checking for the specifi
Ivan Pozdeev via Python-Dev wrote:
the documentation seems to use "sequence" in the sense
"finite iterable". Functions that need to know the length of input in
advance seem to be the minority.
The official classifications we have are:
Sequence: __iter__, __getitem__, __len__
Iterable: __iter
Terry Reedy wrote:
I am surprised that a C-API function calls something a 'sequence'
without it having __len__.
It's a bit strange that PySequence_Check exists at all.
The principle of duck typing would suggest that one
should be checking for the specific methods one needs.
I suspect it's a ho
On 22 June 2018 at 20:17, Ivan Pozdeev via Python-Dev
wrote:
> On 22.06.2018 22:07, Terry Reedy wrote:
>> 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 functio
On 22.06.2018 22:17, Ivan Pozdeev wrote:
On 22.06.2018 22:07, Terry Reedy wrote:
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 obtai
On 22.06.2018 22:07, Terry Reedy wrote:
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/re
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 pla
On 22 June 2018 at 21:45, Christian Tismer wrote:
> Answering myself:
>
> PySequence_Check determines a sequence. See the docs.
>
> len() can but does not have to exist.
> The size is always limited.
Just to throw a couple of extra wrinkles on this:
Due to a C API implementation detail in CPytho
Answering myself:
PySequence_Check determines a sequence. See the docs.
len() can but does not have to exist.
The size is always limited.
After evicting my initial fault, this is now obvious.
Sorry about the noise.
On 22.06.18 13:17, Christian Tismer wrote:
> Hi Brett,
>
> because you did not
Hi Brett,
because you did not understand me, I must have had a fundamental
misunderstanding. So I started a self-analysis and came to the
conclusion that this was my error since maybe a decade:
When iterators and generators came into existence, I somehow
fell into the trap to think that there are
Sorry, I don't quite follow.
On Thu, 21 Jun 2018 at 08:50 Christian Tismer wrote:
> Hi friends,
>
> there is a case in the Python API where I am not sure what to do:
>
> If an object defines __getitem__() only but no __len__(),
> then PySequence_Check() already is true and does not care.
>
Whic
Hi friends,
there is a case in the Python API where I am not sure what to do:
If an object defines __getitem__() only but no __len__(),
then PySequence_Check() already is true and does not care.
So if I define no __len__, it simply fails. Is this intended?
I was mislead and thought this was the
12 matches
Mail list logo