logo       

RE: creating custom arrays / extending java.util.A rrayList: msg#00066

lang.jython.user

Subject: RE: creating custom arrays / extending java.util.A rrayList



Here is __getitem__ from org/python/core/PyInstance.java:

public PyObject __getitem__(PyObject key) {
CollectionProxy proxy = getCollection();
if (proxy != CollectionProxy.NoProxy) {
PyObject ret = proxy.__finditem__(key);
if (ret == null) {
throw Py.KeyError(key.toString());
}
return ret;
}

PyObject ret = trySlice(key, "__getslice__", null);
if (ret != null)
return ret;

return invoke("__getitem__", key);
}


You can see that the code checks whether your instance
is a collection first and calls its __finditem__ before
calling your __getitem__ method.

You might try extending org.python.core.PyList.



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise