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

org.python.core.PyCell 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
/* Copyright (c) Jython Developers */
package org.python.core;

import org.python.expose.ExposedGet;
import org.python.expose.ExposedType;

/**
 * The Python cell type.
 * 
 * Cells are used to implement variables referenced by multiple
 * scopes.
 */
@ExposedType(name = "cell", isBaseType = false)
public class PyCell extends PyObject {

    /** The underlying content of the cell, or null. */
    public PyObject ob_ref;

    @ExposedGet(name = "cell_contents")
    public PyObject getCellContents() {
        if (ob_ref == null) {
            throw Py.ValueError("Cell is empty");
        }
        return ob_ref;
    }

    @Override
    public String toString() {
        if (ob_ref == null) {
            return String.format("", Py.idstr(this));
        }
        return String.format("", Py.idstr(this),
                             ob_ref.getType().getName(), Py.idstr(ob_ref));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy