why no 'length' method in sequences ?
Just van Rossum
just at xs4all.nl
Fri Apr 19 03:35:04 EDT 2002
In article <E4Iv8.2972$8D3.78501 at news1.tin.it>,
Alex Martelli <aleax at aleax.it> wrote:
> Everything IS "consistently object-oriented" -- polymorphism is the
> principal magic of object-orientedness. There would be substantial
> loss of power without measurable conceptual simplification if Python
> had no methods (how would I store a bound-method just as any
> other callable then?) or if it had no functions (serious polymorphism
> loss).
I appreciate and agree with what you write, and I like how Python does
things, too, BUT I can totally see why people find it strange that to
get the length of an object you write
len(o)
and to get (eg.) the keys from a dictionary you do
o.keys()
This seems quite arbitrary, even to me, after maybe 6 years of working
with Python. If o.__len__() were spelled o.len(), we could easily do
without the len() builtin. (Note that I don't argue we could do without
functions: I wouldn't want to miss them for the world...)
Just
More information about the Python-list
mailing list