Merging Objects

Cloudthunder digitalorganics at gmail.com
Mon Apr 3 12:55:04 EDT 2006


Question: how do I merge two objects? I would like to be able to have an
instance of Foo and an instance of Boo and then be able to add them together
and create a new object that has the methods and properties of both objects.
I am going to be doing a lot of this and I don't want to have to dynamically
(or otherwise) create a whole bunch of classes that inherit from both Foo
and Boo then create instances of those new children classes. In fact, this
wouldn't work for me anyway because I am going to have an instance of Foo
which will be used within my algorithm for sometime then later I will want
to merge it with a fresh instance of Boo or otherwise give it all the
methods and properties of the Boo class. Am I making any sense here?

Thanks.

 - OP

P.S. I also noticed that we can no long use the __members__ property to get
a tuple of all a class's methods. How can I get the same info from dir()?
Dir(), I understand, tells you about all properties and you can't tell it to
just list the methods.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060403/1bb1d52e/attachment.html>


More information about the Python-list mailing list