use of org.cafebabepy.runtime.object.java.PyListObject in project cafebabepy by cafebabepy.
the class PyListType method __getitem__.
@DefinePyFunction(name = __getitem__)
public PyObject __getitem__(PyObject self, PyObject key) {
if (!(self instanceof PyListObject)) {
throw this.runtime.newRaiseTypeError("descriptor '__getitem__' requires a 'list' object but received a '" + self.getType().getFullName() + "'");
}
if (!(key instanceof PyIntObject)) {
throw this.runtime.newRaiseTypeError("list indices must be integers or slices, not " + key.getType().getFullName());
}
PyListObject list = (PyListObject) self;
PyIntObject index = (PyIntObject) key;
return list.get(index);
}
Aggregations