changeset 144:4288fbbbc4fb

created
author 127.0.0.1
date Sat, 29 Jun 2013 16:04:42 +0200
parents bcd6ddbb91e3
children ac8fca3d8c16
files ___iter__
diffstat 1 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/___iter__	Sat Jun 29 15:59:56 2013 +0200
+++ b/___iter__	Sat Jun 29 16:04:42 2013 +0200
@@ -1,14 +1,13 @@
 {{{#!python
-class MyIterable(object):
-    def __iter__(self):
-        return MyIterator()
+
+for item in sequence:
+   ...
 
-class MyIterator(object):
-    def __init__(self):
-        self.count = 0
-    def next(self):
-        if self.count >= 9:
-            raise StopIteration()
-        self.count += 1
-        return self.count
+_iterator = sequence.__iter__()
+while True:
+    try:
+        item = _iterator.next()
+    except StopIteration():
+        break
+    ...
 }}}
\ No newline at end of file