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


Groups > comp.lang.python > #64695

Re: Class and instance related questions.

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 <rosuav@gmail.com>
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 <b781b5d3-5dc0-4a7e-9792-78aadf2d6ab4@googlegroups.com>
References <b781b5d3-5dc0-4a7e-9792-78aadf2d6ab4@googlegroups.com>
Date Sat, 25 Jan 2014 03:37:29 +1100
Subject Re: Class and instance related questions.
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5949.1390581460.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sat, Jan 25, 2014 at 3:31 AM, Asaf Las <roegltd@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Class and instance related questions. Asaf Las <roegltd@gmail.com> - 2014-01-24 08:31 -0800
  Re: Class and instance related questions. Chris Angelico <rosuav@gmail.com> - 2014-01-25 03:37 +1100
    Re: Class and instance related questions. Asaf Las <roegltd@gmail.com> - 2014-01-24 12:32 -0800
      Re: Class and instance related questions. Chris Angelico <rosuav@gmail.com> - 2014-01-25 07:45 +1100
        Re: Class and instance related questions. Asaf Las <roegltd@gmail.com> - 2014-01-24 13:03 -0800
          Re: Class and instance related questions. Chris Angelico <rosuav@gmail.com> - 2014-01-25 08:18 +1100
            Re: Class and instance related questions. Asaf Las <roegltd@gmail.com> - 2014-01-24 14:08 -0800
          Re: Class and instance related questions. Dave Angel <davea@davea.name> - 2014-01-24 18:58 -0500
      Re: Class and instance related questions. Terry Reedy <tjreedy@udel.edu> - 2014-01-24 20:08 -0500

csiph-web