Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'attributes': 0.05; 'subject:object': 0.07; 'append': 0.09; 'iterate': 0.09; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'class,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.16; 'jan': 0.19; 'possibly': 0.19; 'trying': 0.20; 'header:In-Reply-To:1': 0.22; 'found,': 0.23; 'itself,': 0.23; 'pm,': 0.26; 'lee': 0.28; 'message-id:@mail.gmail.com': 0.28; 'explicit': 0.28; 'sun,': 0.30; 'objects': 0.32; 'list': 0.32; 'to:addr:python-list': 0.33; 'object': 0.33; 'list.': 0.34; 'something': 0.35; 'received:google.com': 0.37; 'easiest': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'created': 0.38; 'received:209': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'your': 0.61; '29,': 0.67; '"remove"': 0.82; 'subject:others': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=dBfqmAczx0ngcUDULor8ZWKTjFSBuFIUlLv6pXis+Z4=; b=OxUhXwVNQnVjqeZBx6QIBl8Rg2bEisxpXc9j3ZOprFWM5Cqh7pItY4e9G/y61pPK4f cOOFRHWwNTQz766qaxWyOmKQdaCGNuMR3TFxdI4QbIb9SHMtI5pBYLLR/WKSKwWMZS74 dja7+smgLUMz4IlCZf5OdzZNgLvIR/p2ZNkzA= MIME-Version: 1.0 In-Reply-To: References: Date: Sun, 29 Jan 2012 15:02:36 +1100 Subject: Re: object aware of others From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1327809759 news.xs4all.nl 6862 [2001:888:2000:d::a6]:33078 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19566 On Sun, Jan 29, 2012 at 2:48 PM, Lee Chaplin 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