Python: changing methods and attributes at runtime
This example shows the differences between adding a method to a class and to an instance. >>> class Dog(): … def __init__(self, name): … self.name = name … >>> skip = Dog(‘Skip’) >>> spot = Dog(‘Spot’) >>> def talk(self): … print ‘Hi, my name is ‘ + self.name … >>> Dog.talk = talk # add … Read more