Update of /cvsroot/jython/jython/org/python/modules
In directory usw-pr-cvs1:/tmp/cvs-serv15999/modules
Modified Files:
cStringIO.java xreadlines.java
Log Message:
Support for the __iter__ protocol. With this change, all loops over
sequences will use the __iter__() method to get a iterator object and all
builtin sequence objects will ofcourse define the __iter__() method.
Index: cStringIO.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/modules/cStringIO.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** cStringIO.java 2001/11/27 13:51:37 1.12
--- cStringIO.java 2002/01/06 21:19:13 1.13
***************
*** 76,79 ****
--- 76,83 ----
}
+ public PyObject __iter__() {
+ return new PyCallIter(__getattr__("readline"), Py.newString(""));
+ }
+
/**
* Free the memory buffer.
Index: xreadlines.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/modules/xreadlines.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** xreadlines.java 2001/11/05 13:51:29 1.1
--- xreadlines.java 2002/01/06 21:19:13 1.2
***************
*** 29,32 ****
--- 29,36 ----
}
+ public PyObject __iter__() {
+ return new PySequenceIter(this);
+ }
+
public PyObject __finditem__(PyObject idx) {
return __finditem__(idx.__int__().getValue());
|