summaryrefslogtreecommitdiff
path: root/pypers/oxford/gen_with_attr.py
diff options
context:
space:
mode:
Diffstat (limited to 'pypers/oxford/gen_with_attr.py')
-rwxr-xr-xpypers/oxford/gen_with_attr.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/pypers/oxford/gen_with_attr.py b/pypers/oxford/gen_with_attr.py
new file mode 100755
index 0000000..ee1afd5
--- /dev/null
+++ b/pypers/oxford/gen_with_attr.py
@@ -0,0 +1,21 @@
+class MyIter(object):
+ def __iter__(self):
+ yield 1
+ yield 2
+ yield 3
+
+it = MyIter()
+for i in it: print i
+
+i0 = MyIter()
+i1 = iter(i0)
+i2 = iter(i1)
+
+print i0 is i1
+print i1 is i2
+
+it = MyIter()
+print it, iter(it)
+print iter(it), iter(iter(it))
+
+