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


Groups > comp.lang.python > #15536

Re: The python implementation of the "relationships between classes".

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feeder3.cambriumusenet.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.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.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'example:': 0.03; 'python': 0.08; 'subject:python': 0.11; 'am,': 0.12; 'def': 0.14; '(assuming': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:209.85.213.174': 0.16; 'received:mail- yx0-f174.google.com': 0.16; 'subject:between': 0.16; 'subject:classes': 0.16; 'wrote:': 0.18; 'instance': 0.18; 'model,': 0.18; 'dictionary': 0.23; 'header:In-Reply-To:1': 0.23; 'code': 0.25; 'explicitly': 0.28; 'message-id:@mail.gmail.com': 0.29; 'class': 0.29; 'pattern': 0.30; 'chris': 0.30; 'nov': 0.31; 'handling': 0.32; 'list': 0.32; 'to:addr:python-list': 0.32; 'it.': 0.33; 'too': 0.33; 'object': 0.35; 'anything': 0.36; 'fri,': 0.36; 'example,': 0.36; 'references': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'skip:_ 10': 0.40; 'received:209': 0.40; '2011': 0.62; '11,': 0.68; 'subject:The': 0.72; 'container': 0.73; 'composition': 0.84; 'destroyed,': 0.84; 'zhang': 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=6MF5SjzdE5YjmjjRK8csDpfVg+4lWArcT0/R9NoQVVk=; b=TLMADHwY6KLjWHX/HMGb3cb6NTAlgCW+ONx6yA07Ax3V2CICV5LKFCMDssPW71bEQd Ds9yqZCX/XOTh3TN13l2lCl9cHkgUoLejc16KTzMus6WhZvSxprx0RQRyluwcvUiPrcF RQECsiXFVDcX1aoZ90H4CkOANRVdKXlJ6Ml1w=
MIME-Version 1.0
In-Reply-To <CANVwdDr-6x8bt4iNL+Q=jZ7+edk7XbR2K_LeJC3Z60qy=vVFQA@mail.gmail.com>
References <CANVwdDr-6x8bt4iNL+Q=jZ7+edk7XbR2K_LeJC3Z60qy=vVFQA@mail.gmail.com>
Date Fri, 11 Nov 2011 00:26:37 +1100
Subject Re: The python implementation of the "relationships between classes".
From Chris Angelico <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2595.1320931600.27778.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1320931600 news.xs4all.nl 6892 [2001:888:2000:d::a6]:40489
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15536

Show key headers only | View raw


On Fri, Nov 11, 2011 at 12:15 AM, Jerry Zhang <jerry.scofield@gmail.com> wrote:
> For example, in composition model, the container object may be responsible
> for the handling of embedded objects' lifecycle. What is the python pattern
> of such implementation?

Here's an example:

class Test(object):
  def __init__(self):
    self.lst=[1,2,3]
    self.map={"foo":12,"bar":34}

This is a container that has a list and a dictionary in it. When an
instance of the container is destroyed, its list and dictionary will
be destroyed too (assuming nobody's made other references to them).
You don't need to code anything explicitly for that.

Chris Angelico

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


Thread

Re: The python implementation of the "relationships between classes". Chris Angelico <rosuav@gmail.com> - 2011-11-11 00:26 +1100

csiph-web