Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19566 > unrolled thread

Re: object aware of others

Started byChris Angelico <rosuav@gmail.com>
First post2012-01-29 15:02 +1100
Last post2012-01-29 15:02 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: object aware of others Chris Angelico <rosuav@gmail.com> - 2012-01-29 15:02 +1100

#19566 — Re: object aware of others

FromChris Angelico <rosuav@gmail.com>
Date2012-01-29 15:02 +1100
SubjectRe: object aware of others
Message-ID<mailman.5188.1327809759.27778.python-list@python.org>
On Sun, Jan 29, 2012 at 2:48 PM, Lee Chaplin <lchaplin13@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
list.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web