ralhei / pyRserve

A python client for Rserve (network layer to remote R server)
Other
47 stars 13 forks source link

TypeError in TaggedList's __setitem__ and __delitem__ #12

Open rjmorris opened 8 years ago

rjmorris commented 8 years ago

I tried to assign a value to a TaggedList element, but I got the following error:

TypeError: 'builtin_function_or_method' object is not subscriptable

The cause appears to be a mistake in how the index function is called in __setitem__: square brackets are used instead of parentheses. __delitem__ has the same mistake. Compare to __getitem__, which works correctly. The following is from the TaggedList definition in taggedContainers.py from master:

    def __getitem__(self, i):
        if type(i) == str:
            i = self.keys.index(i)
        return self.values[i]

    def __setitem__(self, i, item):
        if type(i) == str:
            i = self.keys.index[i]
        self.values[i] = item

    def __delitem__(self, i):
        if type(i) == str:
            i = self.keys.index[i]
            del self.keys[i]
        del self.values[i]
ralhei commented 8 years ago

Hi rjmorris, yes, this is indeed a bug. I have to revise this class anyway, hope to get there soon.