En Tue, 30 Sep 2008 08:07:18 -0300, Steve Holden <[EMAIL PROTECTED]>
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
--
http://mail.python.org/mailman/listinfo/python-list