Last active
August 29, 2015 14:05
-
-
Save terrycojones/9b3ca3e82e4cf868fa0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
class A(object): | |
def __iter__(self): | |
yield 'i' | |
yield 'am' | |
yield 'A' | |
def fiddleIter(self): | |
def newIter(_): | |
return iter(['i', 'am', 'new']) | |
self.__iter__ = newIter | |
class B(A): | |
def __iter__(self): | |
yield 'i' | |
yield 'am' | |
yield 'B' | |
b = B() | |
b.fiddleIter() | |
print b.__iter__ | |
print list(b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Python 2.7.2 this prints