consistency: extending arrays vs. multiplication ?

Christopher Subich spam.csubich+block at block.subich.spam.com
Sun Jul 24 18:09:32 EDT 2005


Soeren Sonnenburg wrote:
> On Sat, 2005-07-23 at 23:35 +0200, Marc 'BlackJack' Rintsch wrote:
>>Both operate on the lists themselves and not on their contents.  Quite
>>consistent if you ask me.

> But why ?? Why not have them operate on content, like is done on
> *arrays ?

Because they're lists, not arrays.  What do you propose that the 
following do:

[1,2,3] + [4,5,6]
[1,2] + [3,4,5]
[1,2] + [{3:4,5:6}]
dict_var_1.keys() + dict_var_2.keys()
[g(3) for g in [f1 f2 f3] + [f4 f5 f6]]

I point out that the idiom is <list> + <list>, not <numbers> + 
<numbers>.  Operations on lists must deal with them as lists, not lists 
of any specific type.



More information about the Python-list mailing list