Indexing list of lists
__peter__ at web.de
Wed Sep 17 16:51:58 CEST 2003
Hilde Roth wrote:
> Thanks for the suggestion but zip is not nice for large lists
> and as for array/numpy, although I chose a numeric example in
> the posting, I don't see why only numeric arrays should enjoy
> the benefit of such a notation.
> l[;0] is illegal right now but does anyone of any other bit
> of syntax it might conflict with if proposed as an extension?
I think that in alist[from:to:step] the step argument is already overkill.
If there is sufficient demand for column extraction, I would rather make it
a method of list, as alist[:columnIndex] can easily be confused with
alist[;toIndex] (or was it the other way round :-). Would you allow
slicing, too, or make slicing and column extraction mutually exclusive?
Here's how to extract rows 2,4,6 and then columns 4 to 5:
m = n[2:7:2;4:6] # not valid python
Also, ";" is already used (though seldom found in real code) as an alternate
way to delimit statements.
So your suggestion might further complicate the compiler without compelling
benefits over the method approach.
More information about the Python-list