Skip to content

Instantly share code, notes, and snippets.

@nodirt
Created January 23, 2012 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nodirt/1660739 to your computer and use it in GitHub Desktop.
Save nodirt/1660739 to your computer and use it in GitHub Desktop.
Constructor as an argument
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)
@nodirt
Copy link
Author

nodirt commented Jan 23, 2012

Discussion on Google+: http://goo.gl/hfhxP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment