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):
  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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to