dynamic inheritance

Mike Morasky mikem at wetafx.co.nz
Tue May 22 21:28:15 EDT 2001


I've seen this before and I can't remember how to do it, I believe it's very
simple.

class C:

#subclass
class CC(c):

c = C()
c.attribute = "foo"

cc = CC(c)

>>cc.attribute
"foo"

Such that  the "cc" instance of class CC automatically inherits the state of
"c".
Obviously I could say something like cc.__dict__ = c.__dict__ in the __init__
but I thought there was an simpler way to do it

What's the trick to this?

--
 ------- Mike Morasky -------
|                            |
|         Massive TD         |
|        Weta Digital        |
|                            |
|     mikem at wetafx.co.nz     |
|                            |
 ----------------------------


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20010523/fafe25ef/attachment.html>


More information about the Python-list mailing list