Package org.python.core

Examples of org.python.core.PyTuple


            }
            return v;
        }

        private String[] read_strings(int depth) {
            PyTuple t = (PyTuple) read_object_notnull(depth);
            String some_strings[] = new String[t.__len__()];
            int i = 0;
            for (PyObject item : t.asIterable()) {
                some_strings[i++] = item.toString().intern();
            }
            return some_strings;
        }
View Full Code Here


                    }
                    PyObject items[] = new PyObject[n];
                    for (int i = 0; i < n; i++) {
                        items[i] = read_object_notnull(depth + 1);
                    }
                    return new PyTuple(items);
                }

                case TYPE_LIST: {
                    int n = read_int();
                    if (n < 0) {
                        throw Py.ValueError("bad marshal data");
                    }
                    PyObject items[] = new PyObject[n];
                    for (int i = 0; i < n; i++) {
                        items[i] = read_object_notnull(depth + 1);
                    }
                    return new PyList(items);
                }

                case TYPE_DICT: {
                    PyDictionary d = new PyDictionary();
                    while (true) {
                        PyObject key = read_object(depth + 1);
                        if (key == null) {
                            break;
                        }
                        PyObject value = read_object(depth + 1);
                        if (value != null) {
                            d.__setitem__(key, value);
                        }
                    }
                    return d;
                }

                case TYPE_SET:
                case TYPE_FROZENSET: {
                    int n = read_int();
                    PyObject items[] = new PyObject[n];
                    for (int i = 0; i < n; i++) {
                        items[i] = read_object(depth + 1);
                    }
                    PyTuple v = new PyTuple(items);
                    if (type == TYPE_SET) {
                        return new PySet(v);
                    } else {
                        return new PyFrozenSet(v);
                    }
View Full Code Here

               return times;
            }
           
            public PyString __repr__() {
                return (PyString)(Py.newString("repeat(%r, %d)").
                        __mod__(new PyTuple(object, Py.newInteger(counter))));
            }
        };
    }
View Full Code Here

                return object;
            }
                       
            public PyString __repr__() {
                return (PyString)(Py.newString("repeat(%r)").
                        __mod__(new PyTuple(object)));
            }
        };
    }
View Full Code Here

                    // if None is supplied as callable we just return what's in
                    // the iterable(s)
                    if (n == 1) {
                        return args[0];
                    } else {
                        return new PyTuple(args.clone());
                    }
                } else {
                    return callable.__call__(args);
                }
            }
View Full Code Here

                    if (item == null) {
                        return null;
                    }
                    next[i] = item;
                }
                return new PyTuple(next);
            }

        };

    }
View Full Code Here

                if (args != null) {
                    if (!args.getClass().isAssignableFrom(PyTuple.class)) {
                        throw Py.TypeError("iterator must return a tuple");
                    }
                    PyTuple argTuple = (PyTuple) args;
                    // convert to array of PyObjects in call to function
                    result = callable.__call__(argTuple.getArray());
                }
                return result;
            }

        };
View Full Code Here

    /**
     * Create a tuple of iterators, each of which is effectively a copy of iterable.
     */
    public static PyTuple tee(PyObject iterable, final int n) {
        return new PyTuple(PyTeeIterator.makeTees(iterable, n));
    }
View Full Code Here

            return getslice(args[0], Py.None);
        default:
            PyObject[] result = new PyObject[args.length];
            for (int i = 0; i < args.length; i++)
                result[i] = getslice(args[i], Py.None);
            return new PyTuple(result);
        }
    }
View Full Code Here

        PyObject[] result = new PyObject[groups-1];
        for (int i = 1; i < groups; i++) {
            result[i-1] = getslice_by_index(i, def);
        }
        return new PyTuple(result);
    }
View Full Code Here

TOP

Related Classes of org.python.core.PyTuple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.