Operator Overloading
Peter Maas
peter at somewhere.com
Fri Nov 26 03:45:10 EST 2004
Sebastien Boisgerault schrieb:
> Peter Maas <peter at somewhere.com> wrote in message news:<co48s1$r1f$1 at swifty.westend.com>...
>
>>Sebastien Boisgerault schrieb:
[...]
>>but this is not what the Python Reference Manual says. Im not a
>>Numeric expert but AFAIK Numeric arrays are basically C arrays
>>having [] intrinsically so there's no need no deliver it via
>>__getitem__.
>
>
> I would buy your argument if I couldn't find the "__getitem__" method.
> But it does exist ! Except that it is hidden is the class __dict__ and
> apparently cannot be recovered from the instance.__getitem__ call ...
This is strange because it's not the same behaviour as in a pure
Python class. If you really need __getitem__ you could write a
wrapper (or derive, not sure if it is possible):
class sbArray(object):
def __init__(self, plainarray):
self.data = plainarray
def __getitem__(self, idx):
return self.data[idx]
:)
--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
-------------------------------------------------------------------
More information about the Python-list
mailing list