KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > core > PyCallIter


1 package org.python.core;
2
3 public class PyCallIter extends PyIterator {
4     private PyObject callable;
5     private PyObject sentinel;
6     private int idx;
7
8     public PyCallIter(PyObject callable, PyObject sentinel) {
9         this.callable = callable;
10         this.sentinel = sentinel;
11     }
12
13     public PyObject __iternext__() {
14         PyObject val = null;
15         try {
16             val = callable.__call__();
17         } catch (PyException exc) {
18             if (Py.matchException(exc, Py.StopIteration))
19                 return null;
20             throw exc;
21         }
22         if (val._eq(sentinel).__nonzero__())
23             return null;
24         return val;
25     }
26
27 }
28
29
Popular Tags