Created
January 23, 2012 04:59
-
-
Save nodirt/1660739 to your computer and use it in GitHub Desktop.
Constructor as an argument
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
def mymap(fn, iterable): | |
for x in iterable: | |
yield fn(x) | |
class A(object): | |
def __init__(self, x): | |
self.x = x | |
instances = mymap(A, [1, 2, 3]) | |
for a in instances: | |
print(a.x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussion on Google+: http://goo.gl/hfhxP