object aware of others

Chris Angelico rosuav at gmail.com
Sat Jan 28 23:02:36 EST 2012

On Sun, Jan 29, 2012 at 2:48 PM, Lee Chaplin <lchaplin13 at gmail.com> wrote:
> I am trying to create an object that is aware of other objects created
> before itself, and when found, then copy some attributes from them,
> something like:

If you're looking only at other objects of the same class, the easiest
way is to maintain a list every time one is created. Then you just
iterate over that list to know about your friends.

To do this, just append to the list in __init__, and possibly have an
explicit "destroy" or "remove" method that will take self out of that


More information about the Python-list mailing list