Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19566
| References | <CAJ_5dtqyOLYN45G-N2V+bHpRGqsHh6PJi2aoNXAbuKM=YFCD=Q@mail.gmail.com> |
|---|---|
| Date | 2012-01-29 15:02 +1100 |
| Subject | Re: object aware of others |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5188.1327809759.27778.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: object aware of others Chris Angelico <rosuav@gmail.com> - 2012-01-29 15:02 +1100
csiph-web