Merging Objects

Jesus Rivero - (Neurogeek) jrivero at python.org.ve
Mon Apr 3 14:05:39 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>> help(getattr) help(setattr)

Regards,

  Jesus Rivero - (Neurogeek)

Cloudthunder wrote:

> 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.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEMWPzdIssYB9vBoMRAnkLAJ4mkUTlB9POlOyE5MeHukAJ5LeawQCghtoQ
Dsn33bw0LYFsNS2AYStPLdU=
=Dt4g
-----END PGP SIGNATURE-----




More information about the Python-list mailing list