Greetings:
As you know, there are several kinds of relationships between classes in
the UML -- dependency, association, aggregation, composition.
Q1. Is there any article or code example on its implementation in python?
Q2. For example, in composition model, the container object may be
On Fri, Nov 11, 2011 at 12:15 AM, Jerry Zhang jerry.scofi...@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):
Hi Chris,
Firstly thanks for your quick reply.
1. Your code example gives a point, but i may not reach my question yet,
maybe because i did not make myself understood yet. Here is a more detail
example question.
I have a classes sets described by UML, which could be refered as Cls_A,
Cls_B,
On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang jerry.scofi...@gmail.com wrote:
Cls_a:
def __init__(self):
self.at1 = 1
Cls_b:
def __init__(self):
self.com1 = Cls_a()
def __del__(self):
del self.com1
Is it a right implementation for composition?
Yes,
2011/11/10 Chris Angelico ros...@gmail.com
On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang jerry.scofi...@gmail.com
wrote:
Cls_a:
def __init__(self):
self.at1 = 1
Cls_b:
def __init__(self):
self.com1 = Cls_a()
def __del__(self):
del self.com1
2011/11/10 Jerry Zhang jerry.scofi...@gmail.com
2011/11/10 Chris Angelico ros...@gmail.com
On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang jerry.scofi...@gmail.com
wrote:
Cls_a:
def __init__(self):
self.at1 = 1
Cls_b:
def __init__(self):
self.com1 = Cls_a()
On Thu, 2011-11-10 at 22:25 +0800, Jerry Zhang wrote:
2011/11/10 Chris Angelico ros...@gmail.com
On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang
jerry.scofi...@gmail.com wrote:
Cls_a:
def __init__(self):
self.at1 = 1
Cls_b:
Am 10.11.2011 17:09, schrieb Tim Wintle:
Meanwhile, I have a ZODB running, which stores all the living
objects.
The ZODB is append only and stores all objects. Deleting references to
an object (which would causes deletion of standard python objects) won't
delete it from the zodb, it'll
2011/11/11 Tim Wintle tim.win...@teamrubber.com
On Thu, 2011-11-10 at 22:25 +0800, Jerry Zhang wrote:
2011/11/10 Chris Angelico ros...@gmail.com
On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang
jerry.scofi...@gmail.com wrote:
Cls_a:
def
2011/11/11 Christian Heimes li...@cheimes.de
Am 10.11.2011 17:09, schrieb Tim Wintle:
Meanwhile, I have a ZODB running, which stores all the living
objects.
The ZODB is append only and stores all objects. Deleting references to
an object (which would causes deletion of standard python
On Thu, Nov 10, 2011 at 1:06 PM, Jerry Zhang jerry.scofi...@gmail.com wrote:
I just did an example code to describe what i am looking for.
/**/
# ...
class Head:
def __init__(self):
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,
Benjamin Kaplan wrote:
You're still misunderstanding Python's object model. del does NOT
delete an object. It deletes a name. The only way for an object to be
deleted is for it to be inaccessible (there are no references to it,
or there are no reachable references to it).
foo = object()
bar =
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
On Thu, Nov 10, 2011 at 2:48 PM, Steven D'Aprano
steve+comp.lang.pyt...@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
On Fri, Nov 11, 2011 at 10:14 AM, Chris Kaynor ckay...@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
2011/11/11 Benjamin Kaplan benjamin.kap...@case.edu
On Thu, Nov 10, 2011 at 1:06 PM, Jerry Zhang jerry.scofi...@gmail.com
wrote:
I just did an example code to describe what i am looking for.
2011/11/11 Terry Reedy tjre...@udel.edu
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
2011/11/11 Chris Angelico ros...@gmail.com
On Fri, Nov 11, 2011 at 10:14 AM, Chris Kaynor ckay...@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
A general description of my issue.
To my understand, python's feature such as name-reference-object and
garbage collection system did some of work for you, it makes your life
easier, but you still need to add your explicit application in your code.
For example,
Composition implementation: you
20 matches
Mail list logo