LJ Archive

Listing 1. Installing a Mix-in Dynamically

> python
Python 2.0 (#1, Oct 16 2000, 18:10:03)
[GCC 2.95.2 19991024 (release)] on linux2
>>>
>>>class Friendly:
...     def hello(self):
...             print 'Hello'
...
>>> class Person:
...     pass
...
>>> p = Person()
>>> p.hello()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'Person' instance has no attribute 'hello'
LJ Archive