21 Jul
2010
21 Jul
'10
12:15 a.m.
Den 21.07.2010 01:38, skrev Carl M. Johnson:
Does this need new syntax? Couldn’t it just be a method? Perhaps .where()? ;-)
It is just a library issue. And adding it would not break anything, because lists and tuples don't accept iterables as indexers now. The problem is the dict and the set, which can take tuples as index. A .where() method would work, if it e.g. took a predicate as argument. But we would still need no pass the return value (e.g. a tuple) to the [] operator. That is all legal syntax today (which is why NumPy can do this), but lists are implemented to only accept integers to __setitem__ and __getitem__. Sturla