Is there a Python equivalent for Ruby\'s define_method, which would allow dynamic generation of class methods? (as can be seen in Wikipedia\'s Ruby example code
define_method
In Python, you can just set a method on a class:
>>> class Spam: ... def __init__(self, x): ... self.value = x ... >>> Spam.getvalue = lambda self: self.value >>> ham = Spam('ham') >>> ham.getvalue() 'ham'
Fancier stuff is possible with decorators.