Python complaints
Alex Martelli
Alex.Martelli at think3.com
Wed Dec 15 11:36:14 EST 1999
> Mike Fletcher wrote:
[snip]
> I think all functions that operate on single things should be able to
> operate on a list of things and return a list of things. (Are there
> obvious reasons why this paradigm can't work?) Consider,
>
Isn't "len" one such "obvious reason"...?
> >>> l = [1,2,3]
> >>> m = [l,l]
> >>> len(l)
> 2
> >>> len(m)
> 3
>
> I want len(m) to return [3,3]. And I want: max(len(m)) to return 3, etc.
>
But what about len([1, "hello", 2, "foo", 3])? I want it to
return 5, as it does now. If it gives me [0. 5. 0. 3. 0] (or
however else it encodes the "length" of a scalar number)
how do I find out that it just gave me 5 elements, which is
all I care about? Do I hear a suggestion to call len on
the result...?-)
Alex
More information about the Python-list
mailing list