Skip to content

Instantly share code, notes, and snippets.

View ghaering's full-sized avatar

Gerhard Häring ghaering

View GitHub Profile
@ghaering
ghaering / gist:7320226
Created November 5, 2013 14:54
Dynamic method creation does not work as excpected
>>> class API:
... def __init__(self):
... pass
...
>>> for i in range(10):
... name = "print_number_%i" % i
... def print_func(self):
... print "my result is", i
... setattr(API, name, print_func)
...