[Python-ideas] fancy indexing
Sturla Molden
sturla at molden.no
Wed Jul 21 02:15:15 CEST 2010
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
More information about the Python-ideas
mailing list