All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tests.java.org.python.tests.mro.GetitemAdder Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

There is a newer version: 2.7.4
Show newest version
package org.python.tests.mro;

import org.python.core.PyBuiltinMethod;
import org.python.core.PyBuiltinMethodNarrow;
import org.python.core.PyObject;
import org.python.core.PyType;

public class GetitemAdder {

    public static void addPostdefined() {
        PyBuiltinMethod meth = new PyBuiltinMethodNarrow("__getitem__", 1) {

            @Override
            public PyObject __call__(PyObject arg) {
                return arg;
            }
        };
        PyType.fromClass(PostdefinedGetitem.class).addMethod(meth);
    }

    public static void addPredefined() {
        PyBuiltinMethod meth = new PyBuiltinMethodNarrow("__getitem__", 1) {

            @Override
            public PyObject __call__(PyObject arg) {
                return arg;
            }
        };
        PyType.fromClass(FirstPredefinedGetitem.class).addMethod(meth);
        PyType.fromClass(SecondPredefinedGetitem.class).addMethod(meth);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy