Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'class,': 0.07; 'subject:instance': 0.09; 'subject:related': 0.09; 'cc:addr :python-list': 0.11; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'metaclass': 0.16; 'retains': 0.16; 'unbind': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'question': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; '25,': 0.31; 'class': 0.32; 'another': 0.32; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'instances': 0.36; 'possible': 0.36; 'las': 0.37; 'list': 0.37; 'track': 0.38; 'itself': 0.39; 'delete': 0.39; 'system.': 0.39; 'how': 0.40; 'disappear': 0.84; 'itself?': 0.84; 'subject:Class': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=YSZOM3qAFT3D59zycfAIwuFfuBmerrOrxtzTXbNe88w=; b=Nef3WQpM938e+VPWmaTsR59LDB0O4FpyCMaLNDF9gj4N//Nstf7426TTyKmAskQCMv 3oyGn+36WmKxrUDICFU56FCvt+c+EPc87ZqIrdW6cvIBY5K3asSLgEgu/IqzI74sUvCd GKpCOy99VkvYDZ8LNVDyGcxFCSeDLulK+OwtpPx4bEgoley3nVtE53cYXNp54/wSRCH8 owXLTj7tLuGxMu74xXFRbggCAsAVZK7FlkqABhzzlEzjkhSkcDKFJygw8nGLktuhW0Yy AZhFn9ShcRiPnW1Y3e6vIBjiwPBdt/nYvWPgvHkgDZwduRtRzH5KnOpzh1jwkkfpTO7U +Ycw== MIME-Version: 1.0 X-Received: by 10.68.108.194 with SMTP id hm2mr15609610pbb.22.1390581449668; Fri, 24 Jan 2014 08:37:29 -0800 (PST) In-Reply-To: References: Date: Sat, 25 Jan 2014 03:37:29 +1100 Subject: Re: Class and instance related questions. From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390581460 news.xs4all.nl 2923 [2001:888:2000:d::a6]:36394 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64695 On Sat, Jan 25, 2014 at 3:31 AM, Asaf Las wrote: > Hi > > Is there way to get list of instances of particular > class through class itself? via metaclass or any other method? Not automatically, but you can make a class that keeps track of its instances with a weak reference system. > Another question - if class is object is it possible > to delete it? If it is possible then how instances > of that class will behave? It's possible to unbind the name, but every instance retains a reference to its class, so the class itself won't disappear until there are no instances left of it. ChrisA