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