[PYTHON MATRIX-SIG] take() from python sequence
Emmanuel Viennet
viennet@ura1507.univ-paris13.fr
Tue, 28 Jan 1997 11:46:51 GMT
The take() method works on arbitrary sequence object,
but NOT on user defined class instances acting like sequences
(ie defining __getitem__() and __len__() methods).
Why this restriction ?
Example:
class SillySeq:
def __getitem__(self, i):
return i
def __len__(self):
return 100
myseq = SillySeq()
index = arange(10)
take( myseq, index )
=> ValueError: invalid input sequence
P.S.: the restriction is enforced by arrayobject.c/discover_depth(),
but Assign_Array() seems to call __getitem__(), so the
restriction does not seems necessary.
--
Emmanuel Viennet: <viennet@ura1507.univ-paris13.fr>
LIPN - Institut Galilee - Universite Paris-Nord
93430 Villetaneuse - France
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________