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


Groups > comp.lang.python > #15557 > unrolled thread

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

Started byTerry Reedy <tjreedy@udel.edu>
First post2011-11-10 14:38 -0500
Last post2011-11-11 10:39 +1100
Articles 4 — 4 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: The python implementation of the "relationships between classes". Terry Reedy <tjreedy@udel.edu> - 2011-11-10 14:38 -0500
    Re: The python implementation of the "relationships between classes". Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-10 22:48 +0000
      Re: The python implementation of the "relationships between classes". Chris Kaynor <ckaynor@zindagigames.com> - 2011-11-10 15:14 -0800
      Re: The python implementation of the "relationships between classes". Chris Angelico <rosuav@gmail.com> - 2011-11-11 10:39 +1100

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

FromTerry Reedy <tjreedy@udel.edu>
Date2011-11-10 14:38 -0500
SubjectRe: The python implementation of the "relationships between classes".
Message-ID<mailman.2614.1320953960.27778.python-list@python.org>
On 11/10/2011 9:31 AM, Jerry Zhang wrote:

>     Unfortunately there is a difference between composition and
>     aggregation in my real word, and my application really care this
>     since it is trying to simulate this real world model, so my system
>     should track this difference accurately, otherwise the system may
>     not work well.
>
>     For example,
>     a. the Cls_arm and Cls_body may be composition, but not aggregation.
>     My app must ensure that " one arm instance only live with one body
>     instance, if the body instance die, the arm instance must die.

Create the arm as a private member '_arm' of body and make sure that no 
method of body passes out a reference to the arm. (In Python, outside 
code can still grab a reference to the private attribute, but that is a 
coding bug.)

I will point out that in the real world, dead donor transplants are 
based on the fact the parts of the body do NOT have to die when the 
composition does. I will not be surprised if we someday see arm transplants.

-- 
Terry Jan Reedy

[toc] | [next] | [standalone]


#15567

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2011-11-10 22:48 +0000
Message-ID<4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com>
In reply to#15557
On Thu, 10 Nov 2011 14:38:58 -0500, Terry Reedy wrote:

> I will point out that in the real world, dead donor transplants are
> based on the fact the parts of the body do NOT have to die when the
> composition does. I will not be surprised if we someday see arm
> transplants.

And Guido's Time Machine strikes again... not only have there been arm 
transplants, but the first DOUBLE arm transplant was three years ago:

http://www.dailymail.co.uk/health/article-1039587/Worlds-double-arm-transplant-man-gets-teenagers-limbs.html


There have been successful *face* transplants. Nothing will surprise me 
now until they do a brain or head transplant.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#15572

FromChris Kaynor <ckaynor@zindagigames.com>
Date2011-11-10 15:14 -0800
Message-ID<mailman.2629.1320966886.27778.python-list@python.org>
In reply to#15567
On Thu, Nov 10, 2011 at 2:48 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Thu, 10 Nov 2011 14:38:58 -0500, Terry Reedy wrote:
>
>> I will point out that in the real world, dead donor transplants are
>> based on the fact the parts of the body do NOT have to die when the
>> composition does. I will not be surprised if we someday see arm
>> transplants.
>
> And Guido's Time Machine strikes again... not only have there been arm
> transplants, but the first DOUBLE arm transplant was three years ago:
>
> http://www.dailymail.co.uk/health/article-1039587/Worlds-double-arm-transplant-man-gets-teenagers-limbs.html
>
>
> There have been successful *face* transplants. Nothing will surprise me
> now until they do a brain or head transplant.
>

Continuing this OT discussion, would it be a brain transplant, or a
full body transplant?

>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
>

[toc] | [prev] | [next] | [standalone]


#15574

FromChris Angelico <rosuav@gmail.com>
Date2011-11-11 10:39 +1100
Message-ID<mailman.2630.1320968356.27778.python-list@python.org>
In reply to#15567
On Fri, Nov 11, 2011 at 10:14 AM, Chris Kaynor <ckaynor@zindagigames.com> wrote:
> Continuing this OT discussion, would it be a brain transplant, or a
> full body transplant?

It's just a rebinding. You don't move the body, you just bind your
name to a new body. It's perfectly legal to have two names bound to
one body (cf Dr Jekyll and Mr Hyde); if you murder Mr Hyde, you can
still access the body through the other name.

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web