Class PyIterator

    • Field Detail

      • __doc__next

        public static PyString __doc__next
    • Constructor Detail

      • PyIterator

        public PyIterator()
      • PyIterator

        public PyIterator​(PyType subType)
    • Method Detail

      • __iternext__

        public abstract PyObject __iternext__()
        Description copied from class: PyObject
        Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.
        Overrides:
        __iternext__ in class PyObject
      • __iter__

        public PyObject __iter__()
        Description copied from class: PyObject
        Return an iterator that is used to iterate the element of this sequence. From version 2.2, this method is the primary protocol for looping over sequences.

        If a PyObject subclass should support iteration based in the __finditem__() method, it must supply an implementation of __iter__() like this:

         public PyObject __iter__() {
             return new PySequenceIter(this);
         }
         
        When iterating over a python sequence from java code, it should be done with code like this:
         for (PyObject item : seq.asIterable()) {
             // Do somting with item
         }
         
        Overrides:
        __iter__ in class PyObject
      • next

        public PyObject next()
        The exposed next method. Note that exposed derivable subclasses of PyIterator should override next to call doNext(custom___iternext__), as __iternext__ is overridden by the Derived classes.
        Returns:
        a PyObject result
      • iterator

        public java.util.Iterator<java.lang.Object> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Object>
      • __tojava__

        public java.lang.Object __tojava__​(java.lang.Class<?> c)
        Description copied from class: PyObject
        Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special object Py.NoConversion if this PyObject can not be converted to the desired Java class.
        Overrides:
        __tojava__ in class PyObject
        Parameters:
        c - the Class to convert this PyObject to.