What is not objects in Python?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue Sep 30 15:23:41 EDT 2008
En Tue, 30 Sep 2008 08:07:18 -0300, Steve Holden <steve at holdenweb.com>
escribió:
> Terry Reedy wrote:
>> Steven D'Aprano wrote:
>>> Arghh! No!!! |x| should be abs(x), not len(x). Just ask mathematicians
>>> and physicists.
>>
>> It should be both, just as + is addition for numbers and concatenation
>> for sequences. Or we could have just one built-in -- size() instead of
>> abs() and len(). For non-sequence collections, size() would be better
>> than len() anyway.
>>
> And how are these "non-sequence collections" to be distinguished? And
> how does size() differ from len() in that case?
Consider a tree, or a graph. The number of elements they have is not
naturally described as their "length", the usual term is "size" instead.
"Length" is adequate for one-dimensional structures only; even len(dict)
is a bit controversial.
Had Python used the more generic size and __size__ from the beginning,
we'd be all happy now :) But it's too late to change things.
--
Gabriel Genellina
More information about the Python-list
mailing list